GlassContentAwareBrightness class
Gives a single glass control a content-aware light/dark appearance.
This is the per-control consumer of GlassContentAwareScope — the bars
use it internally when adaptiveBrightness: true, and custom glass
controls can wrap themselves in it directly.
The widget resolves the control's Brightness from one of three sources, in priority order:
- brightnessOverride — an external ValueListenable that bypasses the sampler entirely. Use this over PlatformViews, where the content cannot be captured, and drive it from your own signal.
- The enclosing GlassContentAwareScope, by registering the control's rectangle for the per-control contrast vote.
- The ambient platform brightness, when neither is available.
Every verdict change cross-fades rather than snapping: an internal
animation eases darkAmount between 0 (light) and 1 (dark) over
flipDuration with flipCurve (falling back to the scope's values,
then to 200 ms / Curves.easeInOut). During the fade the subtree built
by builder is wrapped so the swap "just works" end to end:
- GlassTheme is replaced with the lerp of its light and dark variants (see GlassThemeVariant.lerp) — themed glass settings, glow palettes and radii cross-fade smoothly.
MediaQuery.platformBrightnessand the CupertinoTheme brightness flip at the fade midpoint, where the blend makes the discrete residue (shadows, resolved dynamic colors in user content) least visible.
onBrightnessChanged fires once per verdict flip — use it to swap colors the package cannot see, such as custom-painted icons.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- GlassContentAwareBrightness
Constructors
-
GlassContentAwareBrightness({required GlassBrightnessWidgetBuilder builder, ValueListenable<
Brightness> ? brightnessOverride, ValueChanged<Brightness> ? onBrightnessChanged, Duration? flipDuration, Curve? flipCurve, int gridColumns = 6, int gridRows = 1, Key? key}) -
Creates a content-aware brightness consumer around
builder.const
Properties
-
brightnessOverride
→ ValueListenable<
Brightness> ? -
External brightness source that bypasses the sampler entirely.
final
- builder → GlassBrightnessWidgetBuilder
-
Builds the control under the brightness overrides.
final
- flipCurve → Curve?
-
Cross-fade curve override; falls back to the scope's
GlassContentAwareScope.flipCurve, then Curves.easeInOut.
final
- flipDuration → Duration?
-
Cross-fade duration override; falls back to the scope's
GlassContentAwareScope.flipDuration, then 200 ms.
final
- gridColumns → int
-
Horizontal voting cells for this control's rect. Defaults to 6 — the
bar-shaped grid. Compact controls should use a square grid (e.g. 2×2).
final
- gridRows → int
-
Vertical voting cells for this control's rect. Defaults to 1.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onBrightnessChanged
→ ValueChanged<
Brightness> ? -
Called when the committed verdict flips (not for the initial value).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< GlassContentAwareBrightness> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited