
Now, suppose we desire to share a specific theme - including the color, brightness, weight, icon styles, and text styles - across our entire app. Lastly, we gave the entire container a margin of 16px, which leaves a space of 16px on each side of the container.īoth of the previous scenarios we’ve discussed - the TextStyle class and the Container widget - deal with the styling of a single component for that particular screen, and do not affect the styling of other TextStyle classes or Container widgets. That provides the container with an excellent rounded shape at the edges instead of the flat edges that comes with the default container.
#THEME COLOR MACHINE CODE#
That gives us a blue line that is 2px in width around the container itself.Īnother styling choice we made in the code block above is altering the border radius we gave it a circular border radius of 16px. Container(Ībove, we assigned the container a color (grey) and gave it a blue border by adjusting the borderColor property. The process for styling the Container widget is similar to what we did for TextStyle however, we achieve styling here by adjusting the properties of the BoxDecoration class, which are then passed to the decoration parameter of the Container widget.

Text("I went for a walk",īy adjusting the properties of the TextStyle class, we have changed the look and feel of the text, and added interest to the overall theme of the application. We’ll do that by adjusting the properties that the TextStyle class offers. We can now add some styling to enhance the look and feel of the app. Text("I went for a walk")įlutter renders this text on the screen with the default color, size, structure, and weight. Flutter provides a TextStyle class that contains several properties that can modify the look and feel of the text widget.
#THEME COLOR MACHINE HOW TO#
In this section, we’ll discuss how to style widgets and containers in Flutter by styling a text widget and the Container widget. This article will touch on each of these methods for theming a Flutter application. There is also complex switching between light and dark theme modes in an application.Īll of these contribute to the overall theme of an application. However, as we highlighted earlier, there are many ways to theme an application that range from altering the look of simple text and icon style, to using styling widgets like the Container widget, TextButton, or RawMaterialButton. You see it when you launch the default counter app: it’s plain blue and white.

What can you use to theme an app in Flutter?įlutter’s MaterialApp comes with a default light blue theme. Everything that makes an application appealing to users comes from theming, and honing your knowledge of Flutter themes will go a long way toward making you a more proficient Flutter developer. It’s what makes your app beautiful, and as personal preferences differ, the specifics behind this can vary across different people.įactors like text styles, text colors, icon styles, and more all contribute to the theme of an application. Theming is the generic name for everything that styles an application to make it look appealing, attractive, and suit your tastes or needs. Chinedu Imoh Follow Chinedu is a tech enthusiast focused on full-stack JavaScript and Infrastructure engineering.
