Switcher class Null safety

A Switcher widget to usage for input bool values.

The Switcher requests a callback Function(bool) named as onChange which will be triggered after the inner control value changed.

If the onChange function is absent, an assertion error will be throw.

assert(onChange != null);
Inheritance

Constructors

Switcher({required bool value, required void onChange(bool value), Duration duration = const Duration(milliseconds: 100), double size = 24.0, Color? activeColor, Color? disableColor})
The default Switcher constructor that render a square shaped Switcher.
Switcher.label({required bool value, required void onChange(bool value), required String? label, TextStyle? labelStyle = const TextStyle(), MainAxisAlignment mainAxisAlignment = MainAxisAlignment.spaceBetween, Duration duration = const Duration(milliseconds: 100), double size = 24.0, Color? activeColor, Color? disableColor})
The named constructor called label that render a square shaped Switcher with a label.
Switcher.labelAndRounded({required bool value, required void onChange(bool value), required String? label, TextStyle? labelStyle = const TextStyle(), MainAxisAlignment mainAxisAlignment = MainAxisAlignment.spaceBetween, Duration duration = const Duration(milliseconds: 100), double size = 24.0, Color? activeColor, Color? disableColor})
The named constructor called label that render a circle shaped Switcher with a label.
Switcher.rounded({required bool value, required void onChange(bool value), Duration duration = const Duration(milliseconds: 100), double size = 24.0, Color? activeColor, Color? disableColor})
The named constructor called rounded that render a circle shaped Switcher.

Properties

activeColor Color?
The active Color of the Switcher. Is displayed when the inner control value is equal to true. The default value is:
final
disableColor Color?
The disable Color of the Switcher. Is displayed when the inner control value is equal to false. The default value is:
final
duration Duration
The Duration of the Switcher animation on value changed. The default value is:
final
hashCode int
The hash code for this object.
@nonVirtualread-onlyinherited
hasLabel bool
of selected to value if is provided.
read-only
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label String?
The text displayed by the label.
read / write
labelStyle TextStyle?
The style for the label.
read / write
mainAxisAlignment MainAxisAlignment
The alignment for the row that contains the label and the Switcher.
read / write
onChange → void Function(bool value)
The callback function reference that is called after the Switcher value changes. Triggered when the inner control value is changed.
final
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
size double
The size of Switcher.
final
switcherWidget Widget
read-only
value bool
The bool value for Switcher.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
buildSwitcherWithLabel(BuildContext context) Widget
Method that return a Row with the label (Text) and the Switcher.
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.
@protectedinherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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.
@nonVirtualinherited