EmergentSwitch class
Used to toggle the on/off state of a single setting.
The switch itself does not maintain any state. Instead, when the state of the switch changes, the widget calls the onChanged callback. Most widgets that use a switch will listen for the onChanged callback and rebuild the switch with a new value to update the visual appearance of the switch.
bool _switch1Value = false;
bool _switch2Value = false;
Widget _buildSwitches() {
return Row(children: <Widget>[
EmergentSwitch(
value: _switch1Value,
style: EmergentSwitchStyle(
thumbShape: EmergentShape.concave,
),
onChanged: (value) {
setState(() {
_switch1Value = value;
});
},
),
EmergentSwitch(
value: _switch2Value,
style: EmergentSwitchStyle(
thumbShape: EmergentShape.flat,
),
onChanged: (value) {
setState(() {
_switch2Value = value;
});
},
),
]);
}
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- EmergentSwitch
- Annotations
Constructors
-
EmergentSwitch({EmergentSwitchStyle style = const EmergentSwitchStyle(), Key? key, Curve curve = Emergent.defaultCurve, Duration duration = const Duration(milliseconds: 200), bool value = false, ValueChanged<
bool> ? onChanged, double height = 40, bool isEnabled = true}) -
const
Properties
- curve → Curve
-
final
- duration → Duration
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double
-
final
- isEnabled → bool
-
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onChanged
→ ValueChanged<
bool> ? -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- style → EmergentSwitchStyle
-
final
- value → bool
-
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}) → 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
Constants
- minHcDepth → const double