⚠️ This lesson is retired and might contain outdated information.

Using Themes in Flutter to Share Colors and Font Styles

nader dabit
Instructornader dabit
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 2 years ago

In this lesson we’ll learn how to use themes in order to share colors and font styles throughout our application.

Instructor: [00:01] To demonstrate theming, we'll start with a basic material app widget with the theme set to themeData and the home widget set to mainApp. mainApp will contain three widgets, an app bar, a body, and a floating action button. None of these widgets will have any explicit styling. Everything will be inherited from the theme.

[00:29] The first theme property we'll change is the primary color. When we update the primary color to gray, we notice that the app bar turns gray, and the title turns black. Any widget in our application that uses this primary color will now inherit the gray color from the main theme. The next property we'll look at is accent color.

[00:51] When we update the accent color to black, we notice that the floating action button is now black. As with the primary color, any widget in our application using the accent color will now inherit the new accent color of black.

[01:04] We can change the text theme for text within our application by updating the primary text theme property. To demonstrate this, we'll update the title property to be a color of white.

[01:30] To update the main background color, we can update the canvas color property. When we hover over a color in our text editor, we'll notice that we get a list of all of the color swatches available for that color. We can also update the brightness property.

[01:55] The brightness property updates the brightness of the overall theme of the application. This property is used by widgets like buttons to determine what color to pick when not using the primary or accent color. We can also directly access properties of our theme using the context variable.

[02:17] To demonstrate this, we'll update the color of our text widget by accessing the theme.of context primary color. We can also use the primary swatch property to theme our application. The primary swatch property will lay out different colors within our application for properties like primary color, shadow, border, and accent color.

egghead
egghead
~ 21 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today