onColor property
Color
get
onColor
Get the right black or white contrasting onColor for a color.
The onColor is white if the color has brightness dark and black if the color has brightness light.
Use the function to get black/white color typically used for text and
icons when they are placed on a surface/background using color
as its
background color.
Implementation
Color get onColor =>
ThemeData.estimateBrightnessForColor(this) == Brightness.light
? Colors.black
: Colors.white;