FossToggleGroup class Inputs

See the toggle group documentation ↗ or try it live in the playground ↗.
Binds a row or column of toggles to one shared selection. Each FossToggleGroupItem's pressed state is its membership in the group value, and variant and size propagate to every item, so the toggles line up and restyle together.
Use FossToggleGroup.single for a one-of-many choice (a String value that
swaps, and clears to null when the active item is tapped again) or
FossToggleGroup.multiple for independent toggles (a Set<String>). In the
FossToggleVariant.outline variant the items join into one segmented bar
with a shared border and rounded outer ends; in
FossToggleVariant.standard they sit as separate buttons with a small gap.
A null onChanged or enabled: false disables the whole group; an item
own enabled: false disables just that one. Colors, radius, and spacing
come from context.fossTheme; pass a FossToggleGroupStyle to style for
a one-off.
Customize globally by passing your own FossThemeData, or per instance
through the widget's style object. There are no per-instance token props:
to change color, radius, or spacing, change the theme.
See also FossToggle for a single two-state button.
FossToggleGroup.single(
value: alignment,
variant: FossToggleVariant.outline,
onChanged: (v) => setState(() => alignment = v),
children: const [
FossToggleGroupItem(value: 'left', child: Text('Left')),
FossToggleGroupItem(value: 'center', child: Text('Center')),
FossToggleGroupItem(value: 'right', child: Text('Right')),
],
);
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- FossToggleGroup
- Annotations
-
- @FossSince('0.1.1')
Constructors
-
FossToggleGroup.multiple({required List<
FossToggleGroupItem> children, required Set<String> value, required ValueChanged<Set< onChanged, FossToggleVariant variant = FossToggleVariant.standard, FossToggleSize size = FossToggleSize.md, Axis orientation = Axis.horizontal, bool enabled = true, FossToggleGroupStyle? style, Key? key})String> > -
const -
FossToggleGroup.single({required List<
FossToggleGroupItem> children, required String? value, required ValueChanged<String?> onChanged, FossToggleVariant variant = FossToggleVariant.standard, FossToggleSize size = FossToggleSize.md, Axis orientation = Axis.horizontal, bool enabled = true, FossToggleGroupStyle? style, Key? key}) -
const
Properties
-
children
→ List<
FossToggleGroupItem> -
The entries laid out and bound to the selection.
final
- enabled → bool
-
Whether the group accepts input. When false every item is disabled.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- orientation → Axis
-
The layout axis. Defaults to Axis.horizontal.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → FossToggleSize
-
The size, propagated to every item. Defaults to FossToggleSize.md.
final
- style → FossToggleGroupStyle?
-
Per-instance overrides layered on the theme-resolved style.
final
- variant → FossToggleVariant
-
The visual treatment, propagated to every item. Defaults to
FossToggleVariant.standard.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
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