In Flutter App to share colors and font styles throughout the app, we can use themes to perform this in Flutter App. In Flutter there are two ways to define themes: App-wide or using Theme
Widgets that define the colors and font styles for a particular part of our application. In fact, app-wide themes are just Theme
Widgets created at the root of our apps by the MaterialApp
!
We have to define a Theme, we can use it within our own Widgets. The Material Widgets provided by Flutter will use our Theme to set the background colors and font styles for App Bars, Buttons, Check boxes, etc.
Creating an app theme In Flutter App:
If we want to share a Theme containing colors and font styles across our entire app, we have to provide ThemeData
to the MaterialApp
constructor.
If in case no theme
is provided, then Flutter creates a fallback theme under the hood.