FlexColorScheme class
Constructs a ThemeData object from its properties and theming logic, that is returned with toTheme.
Flutter's ThemeData.from is a good starting point for ColorScheme based themes. Currently it has a some gaps leaving a few properties in the theme to their defaults from the standard ThemeData factory constructor, those default values will end up not matching the used ColorScheme, especially in dark mode themes.
FlexColorScheme fixes the gaps and makes it easy to create complete themes using the color scheme concept. FlexColorScheme does not rely on ThemeData.from a ColorScheme for its implementation, it uses the ThemeData factory directly under the hood to create the ThemeData object from FlexColorScheme and a ColorScheme that is used to return a slightly opinionated theme with the toTheme getter.
It can be tedious to define nice color scheme directly with the class default constructor. FlexColorScheme is primarily intended to be used with its two factory constructors FlexColorScheme.light and FlexColorScheme.dark, that can create nice schemes using defaults and computed color values.
FlexColorScheme makes it easier to make a theme where the app bar theme background color is not tied to primary color in light theme mode or to surface color in dark theme mode.
Additionally FlexColorScheme makes it easy to optionally create themes that use so called branded surfaces, that blend in a varying degree of the primary color into surfaces amd backgrounds using four pre-defined tuned levels of blend strength. Branded surface are also described in the Material design guide, but Flutter offers no out of the box help to make such themes. With FlexColorScheme you can use a varying degree of surface and background branding level for any theme you make, both in light and dark themes.
A FlexColorScheme can also adjust the TabBarTheme to fit with the active AppBar background or to be themed to always fit on background/surface colors, if its primary usage will be in e.g. a Scaffold body, or Material surface or canvas.
- Mixed in types
- Annotations
Constructors
- FlexColorScheme({required Brightness brightness, required Color primary, required Color primaryVariant, required Color secondary, required Color secondaryVariant, Color? surface, Color? background, Color? error, Color? scaffoldBackground, Color? appBarBackground, Color? accentColor, Color? onPrimary, Color? onSecondary, Color? onSurface, Color? onBackground, Color? onError, FlexTabBarStyle tabBarStyle = FlexTabBarStyle.forAppBar, double appBarElevation = 0, double bottomAppBarElevation = 0, bool tooltipsMatchBackground = false, bool transparentStatusBar = true, VisualDensity? visualDensity, String? fontFamily, TargetPlatform? platform, Typography? typography})
-
Default constructor that requires its key color properties in
order to make a fully designed color scheme for a ThemeData object.
const
- FlexColorScheme.dark({FlexSchemeColor? colors, FlexScheme? scheme, int usedColors = 4, FlexSurface surfaceStyle = FlexSurface.material, FlexAppBarStyle appBarStyle = FlexAppBarStyle.material, FlexTabBarStyle tabBarStyle = FlexTabBarStyle.forAppBar, double appBarElevation = 0, double? bottomAppBarElevation, Color? surface, Color? background, Color? scaffoldBackground, Color? onPrimary, Color? onSecondary, Color? onSurface, Color? onBackground, Color? onError, bool darkIsTrueBlack = false, bool swapColors = false, bool tooltipsMatchBackground = false, bool transparentStatusBar = true, VisualDensity? visualDensity, String? fontFamily, TargetPlatform? platform, Typography? typography})
-
Creates a dark FlexColorScheme based on the given FlexSchemeColor.
factory
- FlexColorScheme.light({FlexSchemeColor? colors, FlexScheme? scheme, FlexSurface surfaceStyle = FlexSurface.material, int usedColors = 4, FlexAppBarStyle appBarStyle = FlexAppBarStyle.primary, FlexTabBarStyle tabBarStyle = FlexTabBarStyle.forAppBar, double appBarElevation = 0, double? bottomAppBarElevation, Color? surface, Color? background, Color? scaffoldBackground, Color? onPrimary, Color? onSecondary, Color? onSurface, Color? onBackground, Color? onError, bool swapColors = false, bool tooltipsMatchBackground = false, bool transparentStatusBar = true, VisualDensity? visualDensity, String? fontFamily, TargetPlatform? platform, Typography? typography})
-
Creates a light FlexColorScheme based on the given FlexSchemeColor.
factory
Properties
- accentColor → Color?
-
Obsolete property that was originally used as the foreground
color for widgets (knobs, text, overscroll edge effect, etc).
final
- appBarBackground → Color?
-
Background color theme for the app bar.
final
- appBarElevation → double
-
The themed elevation for the app bar.
final
- background → Color?
-
A color that typically appears behind scrollable content.
final
- bottomAppBarElevation → double
-
The themed elevation for the bottom app bar.
final
- brightness → Brightness
-
The overall brightness of this color scheme.
final
- error → Color?
-
The color to use for input validation errors, e.g. for
InputDecoration.errorText.
final
- fontFamily → String?
-
Name of the font family to use as default for the theme.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- onBackground → Color?
-
A color that is clearly legible when drawn on background.
final
- onError → Color?
-
A color that is clearly legible when drawn on error.
final
- onPrimary → Color?
-
A color that is clearly legible when drawn on primary.
final
- onSecondary → Color?
-
A color that is clearly legible when drawn on secondary.
final
- onSurface → Color?
-
A color that is clearly legible when drawn on surface.
final
- platform → TargetPlatform?
-
The platform adaptive widgets should adapt to target and mechanics too.
final
- primary → Color
-
The color displayed most frequently across your app’s screens and
components.
final
- primaryVariant → Color
-
A darker version of the primary color.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scaffoldBackground → Color?
-
The color of the scaffold background.
final
- secondary → Color
-
An accent color that, when used sparingly, calls attention to parts
of your app.
final
- secondaryVariant → Color
-
A darker version of the secondary color.
final
- surface → Color?
-
The background color for widgets like Card, BottomAppBar and Dialogs.
final
- tabBarStyle → FlexTabBarStyle
-
Select preferred style for the default TabBarTheme.
final
- tooltipsMatchBackground → bool
-
Tooltips background color will match the brightness of the theme's
background color.
final
- toScheme → ColorScheme
-
Returns the ColorScheme object defined by FlexColorScheme properties.
no setter
- toTheme → ThemeData
-
Returns the ThemeData object defined by FlexColorScheme properties
and its theming logic.
no setter
- transparentStatusBar → bool
-
When set to
true
, it makes the status bar on Android the same color as the rest of the AppBar. Defaults to true.final - typography → Typography?
-
The color and geometry TextTheme values used to configure
ThemeData.textTheme, ThemeData.primaryTextTheme and
ThemeData.accentTextTheme
.final - visualDensity → VisualDensity?
-
The density value for specifying the compactness of various UI components.
final
Methods
-
copyWith(
{Brightness? brightness, Color? primary, Color? primaryVariant, Color? secondary, Color? secondaryVariant, Color? surface, Color? background, Color? error, Color? scaffoldBackground, Color? appBarBackground, Color? onPrimary, Color? onSecondary, Color? onSurface, Color? onBackground, Color? onError, FlexTabBarStyle? tabBarStyle, double? appBarElevation, double? bottomAppBarElevation, bool? tooltipsMatchBackground, bool? transparentStatusBar, VisualDensity? visualDensity, String? fontFamily, TargetPlatform? platform, Typography? typography}) → FlexColorScheme - Copy the object with one or more provided properties changed.
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringShort(
) → String -
A brief description of this object, usually just the runtimeType and the
hashCode.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Properties
- comfortablePlatformDensity → VisualDensity
-
Returns a VisualDensity that is adaptive to
comfortable
instead of to the defaultcompact
, based on active defaultTargetPlatform.no setter
Static Methods
-
createPrimarySwatch(
Color? color) → MaterialColor -
Create a primary Material color swatch from a given
color
. - Returns a SystemUiOverlayStyle that by default has a system navigation bar style that matches the current theme.