AnyBackground class final
Drawing over something you didn't choose: a wallpaper, a video frame, a gradient, a map.
A palette's background is one color the theme chose. AnyBackground is whatever is actually behind the UI, as real pixels. Build one per image, then ask it:
- AnyBackground.scrimFor: how to make text or an icon legible over it. Draw the answer as a rect (Scrim.paintArgb), around the glyph (Scrim.shadowsWithStroke), or as stacked shadows (Scrim.shadows).
- AnyBackground.sharedBorder: one border tone for surfaces drawn together over it, so they read at one elevation.
Everything here is ARGB ints; Flutter types live in
theming/over_image_flutter.dart. See ADR-001.
The pixels behind some UI, plus the contrast policy to judge them by.
The pixels are reduced lazily, once. Answers are cached, 64 per method.
Constructors
-
AnyBackground(List<
int> _argbs, {required Algo algo, required double contrast}) -
argbsmust be real sampled pixels from what's behind the UI. If downscaling first, use min/max pooling, never averaging: averaged black and white pixels make a mid-gray that hides both. Quantizer clusters are averages too. Alpha is ignored; every pixel is opaque. - AnyBackground.unknown({required Algo algo, required double contrast})
- Nothing is known about what's behind.
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
scrimFor(
int contentArgb, {Usage usage = Usage.text, int? scrimArgb}) → Scrim -
The minimum-opacity scrim that makes
contentArgbmeetusage's contrast against every pixel, and keeps meeting it at every opacity above, so callers may round up freely. - One border tone for surfaces drawn together over this background, so they read at one elevation. Each border keeps its surface's hue.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override