MaterialAdaptiveActions<T extends Object> class
final
A Material primary and overflow action region backed by ActionLayoutResolver.
primaryCapacity is the maximum width available to the action region. The
host owns that layout policy because a widget context can expose the whole
window through MediaQuery, but cannot infer how much width a surrounding
toolbar reserves for its leading widget and title. On every build this
widget creates Material-owned layout options, resolves the supplied
actions, and draws the ordered primary and overflow results without
changing the action collection. The overflow trigger is present only while
the resolved overflow region is non-empty. Menu subtrees retain arbitrary
depth and declaration order.
Layout changes animate one boundary action instead of replacing the whole row. Stable actions remain visible while the changing slot fades and expands or contracts. When one result changes several actions, earlier changes complete immediately and only the final boundary action animates. A variant interrupted by the next change contributes one frozen current frame; structural transitions otherwise finish before the latest boundary starts. The region therefore retains at most one outgoing and one incoming child while rapid capacity updates never accumulate outgoing rows.
The following example places one adaptive action directly in an AppBar:
final save = AdaptiveAction<String>.action(
id: ActionId('save'),
metadata: const ActionMetadata(
label: 'Save',
tooltip: 'Save document',
iconKey: 'save',
),
payload: 'save-document',
);
final appBar = AppBar(
title: const Text('Document'),
actions: [
MaterialAdaptiveActions<String>.moreAction(
actions: ActionCollection(roots: [save]),
primaryCapacity: 160,
onInvoke: (command) => handleCommand(command),
iconBuilder: (context, action) => switch (action.metadata.iconKey) {
'save' => const Icon(Icons.save),
_ => null,
},
),
],
);
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- MaterialAdaptiveActions
Constructors
-
MaterialAdaptiveActions({Key? key, required ActionCollection<
T> actions, required ValueChanged<T> onInvoke, required double primaryCapacity, Iterable<ActionId> primaryOrderOverride = const [], Iterable<ActionId> overflowOrderOverride = const [], ActionLayoutResolver resolver = const ActionLayoutResolver(), int? maxPrimaryActions, MaterialActionIconBuilder<T> ? iconBuilder, MaterialActionButtonBuilder<T> ? actionButtonBuilder, MaterialOverflowButtonBuilder? overflowButtonBuilder, required Widget overflowIcon, String overflowTooltip = '', MaterialActionPresentationCallback<T> ? presentationForAction, MaterialActionPresentation? presentationOverride, MaterialAdaptiveActionsStyle style = const MaterialAdaptiveActionsStyle(), Duration fadeDuration = const Duration(milliseconds: 200), Duration resizeDuration = const Duration(milliseconds: 200), Curve switchInCurve = Curves.easeOut, Curve switchOutCurve = Curves.easeIn}) -
Creates a generic Material primary action region.
const
-
MaterialAdaptiveActions.moreAction({Key? key, required ActionCollection<
T> actions, required ValueChanged<T> onInvoke, required double primaryCapacity, Iterable<ActionId> primaryOrderOverride = const [], Iterable<ActionId> overflowOrderOverride = const [], ActionLayoutResolver resolver = const ActionLayoutResolver(), int? maxPrimaryActions, MaterialActionIconBuilder<T> ? iconBuilder, MaterialActionButtonBuilder<T> ? actionButtonBuilder, MaterialOverflowButtonBuilder? overflowButtonBuilder, MaterialActionPresentationCallback<T> ? presentationForAction, MaterialActionPresentation? presentationOverride, MaterialAdaptiveActionsStyle style = const MaterialAdaptiveActionsStyle(), Widget overflowIcon = const Icon(Icons.more_vert), String overflowTooltip = 'More actions', Duration fadeDuration = const Duration(milliseconds: 200), Duration resizeDuration = const Duration(milliseconds: 200), Curve switchInCurve = Curves.easeOut, Curve switchOutCurve = Curves.easeIn}) -
Creates a Material action region with the conventional More icon.
const
Properties
-
actionButtonBuilder
→ MaterialActionButtonBuilder<
T> ? -
Overrides leaf actions, primary menu triggers, and composite invoke
buttons while preserving the renderer-owned slot constraints.
final
-
actions
→ ActionCollection<
T> -
The action roots and placement constraints to resolve.
final
- fadeDuration → Duration
-
The duration of action and label visibility animations.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
iconBuilder
→ MaterialActionIconBuilder<
T> ? -
Resolves platform-specific icons from the platform-neutral metadata.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- maxPrimaryActions → int?
-
The optional maximum number of root actions shown in primary.
final
-
Whether anchored Material menus animate while opening and closing.
final
-
onInvoke
→ ValueChanged<
T> -
Receives the payload of an enabled action after the user invokes it.
final
- overflowButtonBuilder → MaterialOverflowButtonBuilder?
-
Overrides the overflow trigger without replacing its anchored menu.
final
- overflowIcon → Widget
-
The icon used by the overflow trigger.
final
-
overflowOrderOverride
→ Iterable<
ActionId> -
Region-local overflow ordering applied by the core resolver.
final
- overflowTooltip → String
-
Tooltip and accessibility label for the overflow trigger.
final
-
presentationForAction
→ MaterialActionPresentationCallback<
T> ? -
Selects a primary-button presentation independently for each root action.
final
- presentationOverride → MaterialActionPresentation?
-
Forces one Material primary-button presentation for every root action.
final
- primaryCapacity → double
-
The finite, non-negative width available to the primary action region.
final
-
primaryOrderOverride
→ Iterable<
ActionId> -
Region-local primary ordering applied by the core resolver.
final
- resizeDuration → Duration
-
The duration of boundary width expansion and contraction.
final
- resolver → ActionLayoutResolver
-
The layout resolver used to consume renderer-owned constraints.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- style → MaterialAdaptiveActionsStyle
-
Renderer-owned Material visual and layout configuration.
final
- switchInCurve → Curve
-
The curve used while a boundary action or label appears and expands.
final
- switchOutCurve → Curve
-
The curve used while a boundary action or label disappears and contracts.
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