Skip to content

Instantly share code, notes, and snippets.

@haroonkhan9426
Last active April 6, 2020 14:47
Show Gist options
  • Save haroonkhan9426/cabb76c80b14fdd3878ca089138e70f7 to your computer and use it in GitHub Desktop.
Save haroonkhan9426/cabb76c80b14fdd3878ca089138e70f7 to your computer and use it in GitHub Desktop.
Managing Local State Example
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool isChecked = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Center(
child: Checkbox(
value: isChecked,
onChanged: (newVal) {
setState(() {
isChecked = newVal;
});
})),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment