FossAccordion class Layout

See the accordion documentation ↗ or try it live in the playground ↗.
A stack of collapsible sections: each header toggles a panel of content open or closed, with a rotating chevron and an animated height.
FossAccordion owns the open set. Pass value with onValueChanged to control it, or leave value null and seed initialValue to let the widget hold its own set. In single mode (the default) opening a section closes the others; set multiple to keep any number open. In single mode collapsible lets the open section close on a second tap, so zero can be open.
Colors, type, the chevron rotation, and the panel slide come from
context.fossTheme; pass a FossAccordionStyle 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.
FossAccordion(
initialValue: const {'a'},
children: const [
FossAccordionItem(
value: 'a',
title: Text('Is it accessible?'),
child: Text('Yes. It follows the accessibility pattern.'),
),
FossAccordionItem(
value: 'b',
title: Text('Is it styled?'),
child: Text('Yes. It reads its colors and type from the theme.'),
),
],
);
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- FossAccordion
- Annotations
-
- @FossSince('0.1.1')
Constructors
-
FossAccordion({required List<
FossAccordionItem> children, bool multiple = false, bool collapsible = true, Set<String> ? initialValue, Set<String> ? value, ValueChanged<Set< ? onValueChanged, FossAccordionStyle? style, Key? key})String> > -
const
Properties
-
children
→ List<
FossAccordionItem> -
The ordered sections. Each FossAccordionItem.value must be unique.
final
- collapsible → bool
-
In single mode, whether the open section closes on a second tap (so zero
sections can be open). Ignored when multiple is true. Defaults to true.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
initialValue
→ Set<
String> ? -
The open set when uncontrolled (value is null). The widget owns the set
after seeding.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- multiple → bool
-
Whether more than one section may be open at once. Defaults to false
(single): opening a section closes the others.
final
-
onValueChanged
→ ValueChanged<
Set< ?String> > -
Called with the next open set whenever a section toggles. Fires in both
controlled and uncontrolled modes.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- style → FossAccordionStyle?
-
Per-instance overrides layered on the theme-resolved style.
final
-
value
→ Set<
String> ? -
The open set when controlled. The parent owns the set and the widget
renders it.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< FossAccordion> -
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