dynamic_color 1.0.0 dynamic_color: ^1.0.0 copied to clipboard
Flutter package to obtain dynamic colors on Android S+ and create harmonized color schemes.
dynamic_color #
A Flutter package to obtain dynamic colors on Android S+ and create harmonized color schemes.
Learn more about dynamic color. 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 all ColorScheme
's
semantic and custom 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 and creating
a harmonized color scheme. Essentially, we wrap our MaterialApp
with a
DynamicColorBuilder
, and create:
- a dynamic color scheme that we harmonize
- a fallback color scheme
All examples are hosted on GitHub and can be run with:
cd example
flutter run