BackButton class
A Material Design back icon button.
A BackButton is an IconButton with a "back" icon appropriate for the current TargetPlatform. When pressed, the back button calls Navigator.maybePop to return to the previous route unless a custom onPressed callback is provided.
The onPressed callback can, for instance, be used to pop the platform's navigation stack via SystemNavigator instead of Flutter's Navigator in add-to-app situations.
In Material Design 3, both style's ButtonStyle.iconColor and color are used to override the default icon color of BackButton. If both exist, the ButtonStyle.iconColor will override color for states where ButtonStyle.foregroundColor resolves to non-null.
When deciding to display a BackButton, consider using
ModalRoute.canPopOf(context)
to check whether the current route can be
popped. If that value is false (e.g., because the current route is the
initial route), the BackButton will not have any effect when pressed,
which could frustrate the user.
Requires one of its ancestors to be a Material widget.
See also:
- AppBar, which automatically uses a BackButton in its AppBar.leading slot when the Scaffold has no Drawer and the current Route is not the Navigator's first route.
- BackButtonIcon, which is useful if you need to create a back button that responds differently to being pressed.
- IconButton, which is a more general widget for creating buttons with icons.
- CloseButton, an alternative which may be more appropriate for leaf node pages in the navigation tree.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- IconButton
- BackButton
Constructors
- BackButton({Key? key, Color? color, ButtonStyle? style, VoidCallback? onPressed})
-
Creates an IconButton with the appropriate "back" icon for the current
target platform.
const
Properties
- alignment → AlignmentGeometry?
-
Defines how the icon is positioned within the IconButton.
finalinherited
- autofocus → bool
-
True if this widget will be selected as the initial focus when no other
node in its scope is currently focused.
finalinherited
- color → Color?
-
The color to use for the icon inside the button, if the icon is enabled.
Defaults to leaving this up to the icon widget.
finalinherited
- constraints → BoxConstraints?
-
Optional size constraints for the button.
finalinherited
- disabledColor → Color?
-
The color to use for the icon inside the button, if the icon is disabled.
Defaults to the ThemeData.disabledColor of the current Theme.
finalinherited
- enableFeedback → bool?
-
Whether detected gestures should provide acoustic and/or haptic feedback.
finalinherited
- focusColor → Color?
-
The color for the button when it has the input focus.
finalinherited
- focusNode → FocusNode?
-
An optional focus node to use as the focus node for this widget.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- highlightColor → Color?
-
The secondary color of the button when the button is in the down (pressed)
state. The highlight color is represented as a solid color that is overlaid over the
button color (if any). If the highlight color has transparency, the button color
will show through. The highlight fades in quickly as the button is held down.
finalinherited
- hoverColor → Color?
-
The color for the button when a pointer is hovering over it.
finalinherited
- icon → Widget
-
The icon to display inside the button.
finalinherited
- iconSize → double?
-
The size of the icon inside the button.
finalinherited
- isSelected → bool?
-
The optional selection state of the icon button.
finalinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- mouseCursor → MouseCursor?
-
The cursor for a mouse pointer when it enters or is hovering over the
button.
finalinherited
- onPressed → VoidCallback?
-
The callback that is called when the button is tapped or otherwise activated.
finalinherited
- padding → EdgeInsetsGeometry?
-
The padding around the button's icon. The entire padded icon will react
to input gestures.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedIcon → Widget?
-
The icon to display inside the button when isSelected is true. This property
can be null. The original icon will be used for both selected and unselected
status if it is null.
finalinherited
- splashColor → Color?
-
The primary color of the button when the button is in the down (pressed) state.
The splash is represented as a circular overlay that appears above the
highlightColor overlay. The splash overlay has a center point that matches
the hit point of the user touch event. The splash overlay will expand to
fill the button area if the touch is held for long enough time. If the splash
color has transparency then the highlight and button color will show through.
finalinherited
- splashRadius → double?
-
The splash radius.
finalinherited
- standardComponent → StandardComponentType?
-
An enum value to use to identify this button as a type of
StandardComponentType.
finalinherited
- style → ButtonStyle?
-
Customizes this button's appearance.
finalinherited
- tooltip → String?
-
Text that describes the action that will occur when the button is pressed.
finalinherited
- visualDensity → VisualDensity?
-
Defines how compact the icon button's layout will be.
finalinherited
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
inherited
-
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