Flutter : Themedata

Flutter: Themes

If you want your Flutter app to have a stand out user experience I recommend to use Flutters theme widget. It can be used to define application wide colors , fonts and text styles. This theme can than be referenced within each widget in your app.


Image for post

In Flutter you can design custom themes with material app widget, they can be dark, light or colorful. The style depends on your preferred color set.


Image for post

In android we collect all the theme related data in a resource directory, but in Flutter we are able to declare the theme inside the root widget of the project.

The app theme can than be individualized by defining custom colors, fonts etc. inside the ThemeData widget.

Define Application wide Colors

Declare Application wide Fonts

Declare Application wide TextTheme

The custom application theme has been declared and can be used everywhere within your app using the Theme.of() function. If you worked with Inherited widget before you recognize a similarity (GlobalValues.of()).

Set Theme in Widgets

Recap

Now you are able to declare a custom theme which allows you to define your theme at a central position and reference the attributes everywhere in your app.

 

Comments

Popular posts from this blog

Flutter: Exploring more widgets

Food Delivery App 5 - Firebase Storage for Profile Picture

Flutter: Everything is a widget