onColor property
This getter returns appropriate contrast color based on a given color. It will return a color chosen according to the brightness of this color.
- The Color instance on which this getter is called is used to determine the brightness based on ThemeData.estimateBrightnessForColor method.
- If the estimated brightness is light, it will return a color Colors.black87.
- If the estimated brightness is not light (meaning it's dark), it will return Colors.white.
Implementation
Color get onColor => isLight ? Colors.black87 : Colors.white;