fluent2Step function

Color fluent2Step(
  1. Fluent2ThemeData t,
  2. Color token
)

Fluent's grey token laid over whatever stands under it. By day Fluent draws its greys as steps from white (a disabled fill #F0F0F0, a disabled stroke or a divider #E0E0E0, a selected row #EBEBEB), steps the brand-tinted page all but swallows; laid as the same step of ink (#E0E0E0 is 12% black), it is Fluent's grey on a card and the same step darker on the page. By night, and for a colour that is not a grey, the token.

Implementation

Color fluent2Step(Fluent2ThemeData t, Color token) {
  if (t.brightness == Brightness.dark || token.a < 1) return token;
  final r = (token.r * 255).round();
  final g = (token.g * 255).round();
  final b = (token.b * 255).round();
  if (r != g || g != b) return token;
  return Color.fromARGB(255 - r, 0, 0, 0);
}