NeumorphicSwitch 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>[

     NeumorphicSwitch(
       value: _switch1Value,
       style: NeumorphicSwitchStyle(
         thumbShape: NeumorphicShape.concave,
       ),
       onChanged: (value) {
         setState(() {
           _switch1Value = value;
         });
       },
     ),

     NeumorphicSwitch(
       value: _switch2Value,
       style: NeumorphicSwitchStyle(
         thumbShape: NeumorphicShape.flat,
       ),
       onChanged: (value) {
         setState(() {
           _switch2Value = value;
         });
       },
     ),

   ]);
 }
Inheritance
Annotations

Constructors

NeumorphicSwitch({NeumorphicSwitchStyle style = const NeumorphicSwitchStyle(), Key? key, Curve curve = Neumorphic.DEFAULT_CURVE, 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 NeumorphicSwitchStyle
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

MIN_EMBOSS_DEPTH → const double