Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save felixblaschke/6dad553468b8c080e1b3e7607bdb23d6 to your computer and use it in GitHub Desktop.
Save felixblaschke/6dad553468b8c080e1b3e7607bdb23d6 to your computer and use it in GitHub Desktop.
Example Form for Switchlike Checkbox
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