dynamic_color
A Flutter package to obtain dynamic colors on Android S+ and create harmonized color schemes.
Learn more about dynamic color, custom colors and harmonization on the Material 3 site.
Features
Builder widget
For convenience, this package includes DynamicColorBuilder
, a stateful widget
that provides the device's dynamic colors in a light and dark ColorScheme
.
Plugin
Under the hood, DynamicColorBuilder
uses a plugin to talk to the Android OS.
Color and color scheme harmonization
How do we ensure any particular color (i.e. semantic/custom color) looks good next to a user's dynamically-generated color?
This package provides two extension methods, Color.harmonizeWith()
and
ColorScheme.harmonized()
to accomplish this.
Color.harmonizeWith()
shift the hue of the color towards the passed in
color, typically colorScheme.primary
. This leaves the color recognizable
while harmonizing it.
ColorScheme.harmonized()
does the same thing, for ColorScheme
's
built-in semantic colors. See harmonization.dart for more.
Getting started
flutter pub add dynamic_color
import 'package:dynamic_color/dynamic_color.dart';
Usage
See this complete example for obtaining dynamic colors, creating harmonized color schemes, and harmonizing custom colors.
All examples are hosted on GitHub and can be run with:
cd example
flutter run
Development
The hosted examples can be updated with:
cd example
flutter build web