AdaptiveGlassText class
A Text drop-in that keeps itself readable over a glass surface by sampling the content behind it.
Behavior is governed by the closest enclosing GlassA11yScope (or GlassA11yMode.auto if there is none):
- auto — cross-fades between lightColor and darkColor to track the sampled backdrop, exactly like GlassContentAwareBrightness (which this widget is built on).
- warnOnly — renders a static color resolved from ambient platform brightness, but logs a contrast warning in debug builds when that color fails GlassA11yScopeData.minimumContrast against the sampled backdrop. No-op in release builds.
- off — a static color resolved from ambient platform brightness, with no sampling or registration at all.
Sampling requires a GlassContentAwareScope with a registered GlassContentAwareContent — see GlassLuminanceSampler for why there is no fallback capture. GlassA11yScope installs the scope for you; you still need to mark your actual scrolling content.
AdaptiveGlassText(
'Settings',
lightColor: Colors.black87,
darkColor: Colors.white,
style: theme.textTheme.titleMedium,
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- AdaptiveGlassText
Constructors
- AdaptiveGlassText(String data, {required Color lightColor, required Color darkColor, TextStyle? style, TextAlign? textAlign, int? maxLines, TextOverflow? overflow, bool? softWrap, Key? key})
-
Creates adaptive glass-aware text.
const
Properties
- darkColor → Color
-
Color used when the sampled backdrop is dark (or as the static color
in GlassA11yMode.warnOnly/GlassA11yMode.off when ambient brightness
is dark).
final
- data → String
-
The text to display.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- lightColor → Color
-
Color used when the sampled backdrop is light (or as the static color
in GlassA11yMode.warnOnly/GlassA11yMode.off when ambient brightness
is light).
final
- maxLines → int?
-
Passed through to the underlying Text.
final
- overflow → TextOverflow?
-
Passed through to the underlying Text.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- softWrap → bool?
-
Passed through to the underlying Text.
final
- style → TextStyle?
-
Passed through to the underlying Text;
coloris ignored if set — use lightColor/darkColor instead.final - textAlign → TextAlign?
-
Passed through to the underlying Text.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< AdaptiveGlassText> -
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