FluentSwitchStyle class
The visual configuration of a FluentSwitch.
The same shape as FluentButtonStyle: every visual property is a
WidgetStateProperty, so hover, pressed and disabled values live on the
property rather than being branched on at build time.
The checked/unchecked axis is deliberately not a WidgetState here.
WidgetState.selected is reserved for Fluent's real *Selected tokens, and
a checked switch reaches for an entirely different family
(compoundBrandBackground*, neutralForegroundInverted) rather than a
selected variant of its resting one. Checked is therefore part of
FluentSwitchState, exactly as appearance is for a button, and
resolveFluentSwitchStyle returns a different token set for each.
Every field is nullable and means "inherit". Resolution order, lowest to highest precedence:
- the size/checked defaults derived from the theme
- the nearest
FluentSwitchTheme - the widget's own
style
The consumer's own style therefore wins, matching upstream's rule that
props.className is passed last to mergeClasses.
- Annotations
Constructors
-
FluentSwitchStyle({WidgetStateProperty<
Color?> ? trackColor, WidgetStateProperty<Color?> ? trackBorderColor, WidgetStateProperty<double?> ? trackBorderWidth, WidgetStateProperty<BorderRadius?> ? trackBorderRadius, WidgetStateProperty<Color?> ? thumbColor, WidgetStateProperty<Color?> ? labelColor, WidgetStateProperty<TextStyle?> ? textStyle, WidgetStateProperty<Size?> ? trackSize, WidgetStateProperty<double?> ? thumbSize, WidgetStateProperty<double?> ? thumbTravel, WidgetStateProperty<EdgeInsetsGeometry?> ? trackPadding, WidgetStateProperty<EdgeInsetsGeometry?> ? labelPadding, WidgetStateProperty<MouseCursor?> ? mouseCursor}) -
Creates a style. Omitted properties inherit.
const
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
-
labelColor
→ WidgetStateProperty<
Color?> ? -
Label colour. Separate from thumbColor because upstream recolours the
label only for disabled, and never on hover or press.
final
-
labelPadding
→ WidgetStateProperty<
EdgeInsetsGeometry?> ? -
Space around the label. Directional, because upstream shrinks the padding
on whichever side faces the track.
final
-
mouseCursor
→ WidgetStateProperty<
MouseCursor?> ? -
Cursor while hovering.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
textStyle
→ WidgetStateProperty<
TextStyle?> ? -
Label text style. Its colour is overridden by labelColor.
final
-
thumbColor
→ WidgetStateProperty<
Color?> ? -
Thumb fill. Upstream paints it with the indicator's
color, which is why it transitions on the same spec as the track.final -
thumbSize
→ WidgetStateProperty<
double?> ? -
Painted diameter of the thumb.
final
-
thumbTravel
→ WidgetStateProperty<
double?> ? -
How far the thumb travels when checked, in the reading direction.
final
-
trackBorderColor
→ WidgetStateProperty<
Color?> ? -
Track outline colour. Null and transparent are different: Fluent's
transparentStrokebecomes opaqueCanvasTextin high contrast, which is the only thing outlining a checked switch there.final -
trackBorderRadius
→ WidgetStateProperty<
BorderRadius?> ? -
Track corner radius.
borderRadiusCircularupstream.final -
trackBorderWidth
→ WidgetStateProperty<
double?> ? -
Track outline width. Upstream declares
border: 1px solidon the indicator in every state, checked included.final -
trackColor
→ WidgetStateProperty<
Color?> ? -
Track fill. Transparent while unchecked — as a token, never as
Colors.transparent.final -
trackPadding
→ WidgetStateProperty<
EdgeInsetsGeometry?> ? -
Space around the track. Upstream's
marginon the indicator.final -
trackSize
→ WidgetStateProperty<
Size?> ? -
Outer size of the track, border included — upstream sets
box-sizing: border-box, so the 1px outline eats into these numbers rather than growing them.final
Methods
-
copyWith(
{WidgetStateProperty< Color?> ? trackColor, WidgetStateProperty<Color?> ? trackBorderColor, WidgetStateProperty<double?> ? trackBorderWidth, WidgetStateProperty<BorderRadius?> ? trackBorderRadius, WidgetStateProperty<Color?> ? thumbColor, WidgetStateProperty<Color?> ? labelColor, WidgetStateProperty<TextStyle?> ? textStyle, WidgetStateProperty<Size?> ? trackSize, WidgetStateProperty<double?> ? thumbSize, WidgetStateProperty<double?> ? thumbTravel, WidgetStateProperty<EdgeInsetsGeometry?> ? trackPadding, WidgetStateProperty<EdgeInsetsGeometry?> ? labelPadding, WidgetStateProperty<MouseCursor?> ? mouseCursor}) → FluentSwitchStyle - This style with the given properties replaced.
-
merge(
FluentSwitchStyle? other) → FluentSwitchStyle -
This style with the non-null properties of
otherlayered on top. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
from(
{Color? trackColor, Color? trackBorderColor, double? trackBorderWidth, BorderRadius? trackBorderRadius, Color? thumbColor, Color? labelColor, TextStyle? textStyle, Size? trackSize, double? thumbSize, double? thumbTravel, EdgeInsetsGeometry? trackPadding, EdgeInsetsGeometry? labelPadding, MouseCursor? mouseCursor}) → FluentSwitchStyle - Convenience for the common case of one value across every state.