Skip to content

Instantly share code, notes, and snippets.

@kleinlennart
Last active May 24, 2018 22:59
Template for ThemeData Material Design App Flutter
// in main.dart:
// import 'package:fly_library/res/theme.dart' as Theme;
import 'package:flutter/material.dart';
final ThemeData myAppTheme = new ThemeData(
brightness: Brightness.light,
primarySwatch: Colors.blue,
primaryColor: Colors.blue[500],
primaryColorBrightness: Brightness.light,
accentColor: Colors.pinkAccent[200],
accentColorBrightness: Brightness.light);

Create a [ThemeData] given a set of preferred values. Default values will be derived for arguments that are omitted.

The most useful values to give are, in order of importance:

  • The desired theme [brightness].
  • The primary color palette (the [primarySwatch]), chosen from one of the swatches defined by the material design spec. This should be one of the maps from the [Colors] class that do not have "accent" in their name.
  • The [accentColor], sometimes called the secondary color, and, if the accent color is specified, its brightness ([accentColorBrightness]), so that the right contrasting text color will be used over the accent color.

See https://material.google.com/style/color.html for more discussion on how to pick the right colors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment