MaterialSegmentedControl<T> class
Material Segmented Control
A segmented control like the one for iOS, but in Material Design.
You can use any Widget to make it a segmented item. Simply define a Map with indices.
onSegmentTapped is called whenever a segmented item is clicked.
You need to pass it to selectionIndex to tell MSC what index
is currently selected. Make sure to update it via setState
.
The children are displayed in increasing order of the indeces given in the Map. The width for an item is set to the width of the largest child.
selectedColor and unselectedColor are set to Colors.blue and Colors.white when they are null and are not explicitly required but recommended to set for your needs.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- MaterialSegmentedControl
Constructors
-
MaterialSegmentedControl({Key? key, required Map<
T, Widget> children, ValueChanged<T> ? onSegmentTapped, List<T> ? disabledChildren, T? selectionIndex, Color? borderColor, double verticalOffset = 12.0, double borderRadius = 32.0, double borderWidth = 0.7, TextStyle? selectedTextStyle, TextStyle? unselectedTextStyle, Color selectedColor = _kSelectedDefaultColor, Color? disabledColor = _kDisabledDefaultColor, Color? unselectedColor = _kUnselectedDefaultColor, EdgeInsets horizontalPadding = _horizontalPadding})
Properties
- borderColor → Color?
-
Color used as border color.
final
- borderRadius → double
-
The border radius used on the left and right side.
final
- borderWidth → double
-
The border width used on entire widget.
final
-
children
→ Map<
T, Widget> -
The children to use. They need to live inside a Map
with indices; make sure they are in increasing order.
{@tool sample}
final
-
disabledChildren
→ List<
T> ? -
Define the children to disable.
Giving an empty list or null enables all children.
final
- disabledColor → Color?
-
The background color to use if a child is disabled
by disabledChildren. Defaults to Colors.grey.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- horizontalPadding → EdgeInsets
-
The horizontal padding to apply to the entire widget.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onSegmentTapped
→ ValueChanged<
T> ? -
The callback to use when a segmented item is tapped
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedColor → Color
-
Selected color.
final
- selectedTextStyle → TextStyle?
-
Selected text style.
final
- selectionIndex → T?
-
Currently selected item index. Make sure to pass the value
from onSegmentTapped to see the selection state.
final
- unselectedColor → Color?
-
Unselected color.
final
- unselectedTextStyle → TextStyle?
-
Unselected text style.
final
- verticalOffset → double
-
The padding of a child, vertically.
You can use this to control the height of the widget in most cases.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _SegmentedControlState< T> -
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}) → 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