Created
April 17, 2019 15:20
-
-
Save felixblaschke/6dad553468b8c080e1b3e7607bdb23d6 to your computer and use it in GitHub Desktop.
Example Form for Switchlike Checkbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExampleForm extends StatefulWidget { | |
@override | |
_ExampleFormState createState() => _ExampleFormState(); | |
} | |
class _ExampleFormState extends State<ExampleForm> { | |
bool enableCoolStuff = false; | |
@override | |
Widget build(BuildContext context) { | |
return GestureDetector( | |
onTap: _toggle, | |
behavior: HitTestBehavior.translucent, | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
SwitchlikeCheckbox(checked: enableCoolStuff), | |
Padding( | |
padding: const EdgeInsets.only(left: 20.0), | |
child: Text( | |
"Enable cool stuff", | |
textScaleFactor: 1.3, | |
), | |
) | |
], | |
), | |
); | |
} | |
void _toggle() { | |
setState(() { | |
enableCoolStuff = !enableCoolStuff; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment