switch oscillation on flutter

1,820

This is a known bug that is fixed with an update.

The bug is discussed here: https://github.com/flutter/flutter/issues/17773

Fix commit is here if you wish to fix it for your self by editing the packages/flutter/lib/src/material/toggleable.dart file: https://github.com/flutter/flutter/pull/17821

Share:
1,820
Nitneuq
Author by

Nitneuq

Updated on December 04, 2022

Comments

  • Nitneuq
    Nitneuq over 1 year

    it's my first question here, I'm newbi. I have an issue with switch on flutter.

    I did this simple code like the example but in a certain moment, when I switch quickely, the switch begin to oscillate. how can I fix this problem? thank you

    bool _switchValue = false;
    
    @override
    Widget build(BuildContext context) {
    
    return new Scaffold(
      body: new Container(
        padding: new EdgeInsets.all(32.0),
        child: new Column(
          children: <Widget>[
             new Switch(
              value: _switchValue,
              onChanged: (bool value) { setState(() {
                _switchValue = value;
                  }
                );
              },
            )
          ],
         )
       )
     );
    }