stateLayerColor function

Color stateLayerColor(
  1. Color fill,
  2. Color label
)

The state-layer colour of a key with fill and label: black when the label is lighter than the face, white when it is darker. The layer moves the face away from its label, so the pressed, hover and long-press states can only raise label contrast — a label-coloured layer (the M3 default) would pull a label resting at 4.5:1 down to ≈ 3.7:1 while the key is held (spec §5.4; Accessible lock 7:1).

Implementation

Color stateLayerColor(Color fill, Color label) =>
    label.computeLuminance() > fill.computeLuminance()
    ? const Color(0xFF000000)
    : const Color(0xFFFFFFFF);