onToggle property

ValueChanged<bool> onToggle
final

Called when the user toggles the switch.

This property is required.

onToggle should update the state of the parent StatefulWidget using the setState method, so that the parent gets rebuilt; for example:

FlutterSwitch(
  value: _status,
  width: 110,
  borderRadius: 30.0,
  onToggle: (val) {
    setState(() {
       _status = val;
    });
  },
),

Implementation

final ValueChanged<bool> onToggle;