Skip to content

Instantly share code, notes, and snippets.

@rahulkhatri19
Created December 9, 2019 12:54
Show Gist options
  • Save rahulkhatri19/f9c8fcfcbae313a759ea506650142802 to your computer and use it in GitHub Desktop.
Save rahulkhatri19/f9c8fcfcbae313a759ea506650142802 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(home: SwitchApp()));
}
class SwitchApp extends StatefulWidget {
@override
_switch createState() => new _switch();
}
class _switch extends State<SwitchApp> {
bool swBool = false;
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: new Text('Slider App'),
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Switch(
value: swBool,
onChanged: (bool sw) {
setState(() {
swBool = sw;
});
})
],
)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment