https://github.com/flutter/flutter
Flutter Logo (Google): https://flutter.io/
In this Flutter Video Tutorial, we take a look at how we can implement uniform themes according to the material design specification into our application. We also take a look at the various ways that we can customize and change the different looks and styles to make our application more unique. Finally, look at importing custom fonts and using them inside of our application.
In order to share font styles and colors throughout our application, we need to take advantage of themes. In flutter, there are two main ways that you can define themes; through app wide declarations and on individual widgets. The Material Application Widget contains a property called theme which allows us to insert a ThemeData object which proliferates the colors and styles that we specify throughout our entire application.
This image shows off our Root widget for this application. Inside of this root widget, we create a Theme Data object by calling a function called buildThemeData. This function can be called directly in the theme property of the material application widget.
While uniform themes are a great way to create a consistent look for your application; they can make applications look very similar to each other. This is why we usually want to further customize the themes of our applications through the use of contextual function calls and the copyWith method. The Contextual Function calls allow us to directly fetch the theme data of the root widget anywhere inside of the application. We can then copy this theme data object using the copyWith method and change the properties that we want to change for the widget that we are working on.
In this line of code, we are specifying the color of a widget in our application. Specifically, we are specifying the card color of a card widget. We are able to fetch the entire theme data object using the Theme.of(context) call and then the copyWith method allows us to change the single card color value for this instance of the object. We can then just grab that card color value and pass it into the color property.
Typography and Fonts can be very important in mobile applications. They make text more readable and allow you to draw more attention to various pieces of text. Fonts can make a format look bad or look great depending on how they are integrated into the application. Flutter comes with a few default fonts, however, we are also able to import as many custom font assets as we would like. After importing the fonts, we can directly call them in the dart code by passing a string to a property.
Above you can see the font declarations inside of the pubspec.yaml file for our application. In this file, we are importing two different font families through five different files. Notice that some of the font files are prefaced with weight and style keywords. In Dart, we are able to directly specify which font file should correspond with which font family, font weight and font style. This allows us to call these values inside of our application later in a way that feels comfortable.
The source code for this project can be found here
The FiraCode Font may be found here
The Material Design Color Tool can be found here
Stand Alone Projects:
- Dart Flutter Cross Platform Chat Application Tutorial
- Building a Temperature Conversion Application using Dart's Flutter Framework
- Managing State with Flutter Flux and Building a Crypto Tracker Application with Dart's Flutter Framework
Building a Calculator
- Building a Calculator Layout using Dart's Flutter Framework
- Finishing our Calculator Application with Dart's Flutter Framework
Movie Searcher Application
- Building a Movie Searcher with RxDart and SQLite in Dart's Flutter Framework (Part 1)
- Building a Movie Searcher with RxDart and SQLite in Dart's Flutter Framework (Part 2)
- Building a Movie Searcher with RxDart and SQLite in Dart's Flutter Framework (Part 3, Final)
Minesweeper Game
- Building a Mine Sweeper Game using Dart's Flutter Framework (Part 1)
- Building a Mine Sweeper Game using Dart's Flutter Framework (Part 2)
- Building a Mine Sweeper Game using Dart's Flutter Framework (Part 3)
- Building a Mine Sweeper Game using Dart's Flutter Framework (Part 4, Final)
Weather Application
- Building a Weather Application with Dart's Flutter Framework (Part 1, Handling Complex JSON with Built Code Generation)
- Building a Weather Application with Dart's Flutter Framework (Part 2, Creating a Repository and Model)
- Building a Weather Application with Dart's Flutter Framework (Part 3, RxCommand (RxDart) and Adding an Inherited Widget)
- Building a Weather Application with Dart's Flutter Framework (Part 4, Using RxWidget to Build a Reactive User Interface)
- Localize and Internationalize Applications with Intl and the Flutter SDK in Dart's Flutter Framework