MotionTabBar class
An animated bottom navigation bar.
MotionTabBar renders a row of tab items with a floating, animated
indicator that slides to the currently selected tab. It is designed to be
used as the bottomNavigationBar of a Scaffold, paired with a
TabBarView in the body.
Example:
MotionTabBar(
initialSelectedTab: 'Home',
labels: const ['Home', 'Profile'],
icons: const [Icons.home, Icons.person],
onTabItemSelected: (index) => setState(() {}),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- MotionTabBar
Constructors
-
MotionTabBar({Key? key, TextStyle? textStyle, Color? tabIconColor = Colors.black, double? tabIconSize = 24, Color? tabIconSelectedColor = Colors.white, double? tabIconSelectedSize = 24, Color? tabSelectedColor = Colors.black, Color? tabBarColor = Colors.white, double? tabBarHeight = 65, double? tabSize = 60, Function? onTabItemSelected, required String initialSelectedTab, required List<
String?> labels, List<IconData> ? icons, List<Widget> ? iconWidgets, bool useSafeArea = true, List<Widget?> ? badges, MotionTabBarController? controller, bool labelAlwaysVisible = false}) - Creates a MotionTabBar.
Properties
-
badges
→ List<
Widget?> ? -
Optional badges shown on each tab. The length must match labels;
entries may be
nullto hide the badge for a specific tab.final - controller → MotionTabBarController?
-
Optional MotionTabBarController to change the selected tab
programmatically.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
icons
→ List<
IconData> ? -
Optional IconData icons for each tab. Mutually exclusive with
iconWidgets; either one must be provided.
final
-
iconWidgets
→ List<
Widget> ? -
Optional custom widgets used as tab icons. Mutually exclusive with
icons; either one must be provided.
final
- initialSelectedTab → String
-
The label of the tab that is selected when the widget is first built.
Must be one of labels.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- labelAlwaysVisible → bool
-
Whether tab labels are always visible. When
false(default), only the label of the selected tab is shown.final -
labels
→ List<
String?> -
Labels of the tabs. The length must match icons / iconWidgets.
final
- onTabItemSelected → Function?
-
Callback invoked when a tab is selected, receiving the index of the
newly selected tab.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tabBarColor → Color?
-
Background color of the tab bar.
final
- tabBarHeight → double?
-
Height of the tab bar.
final
- tabIconColor → Color?
-
Color of the unselected tab icons.
final
- tabIconSelectedColor → Color?
-
Color of the selected tab icon (shown inside the floating indicator).
final
- tabIconSelectedSize → double?
-
Size of the selected tab icon (shown inside the floating indicator).
final
- tabIconSize → double?
-
Size of the unselected tab icons.
final
- tabSelectedColor → Color?
-
Background color of the floating indicator circle.
final
- tabSize → double?
-
Size of the floating indicator circle.
final
- textStyle → TextStyle?
-
TextStyle applied to the tab labels.
final
- useSafeArea → bool
-
Whether to wrap the tab bar in a SafeArea (default:
true).final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< MotionTabBar> -
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