Last active
March 19, 2022 18:08
-
-
Save usimsek/8f69e3c41231a2897c6b6a5e4345dc58 to your computer and use it in GitHub Desktop.
flutter SWITCH
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
import 'package:flutter/material.dart'; | |
class SwitchOnchangedListener extends StatefulWidget { | |
@override | |
SwitchOnchangedListenerState createState() { | |
return new SwitchOnchangedListenerState(); | |
} | |
} | |
class SwitchOnchangedListenerState extends State<SwitchOnchangedListener> { | |
bool _isChecked = true; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Swiutch Onchange Listener Example"), | |
), | |
body: Column( | |
children: <Widget>[ | |
Expanded( | |
child: Center( | |
child: Text(_isChecked ? "Switch On" : "Switch Off", | |
style: TextStyle( | |
fontSize: 20.0, | |
fontWeight: FontWeight.bold, | |
color: Colors.red, | |
)), | |
), | |
), | |
Expanded( | |
child: Container( | |
height: 350.0, | |
child: Column( | |
children: [ | |
Switch( | |
value: _isChecked, | |
onChanged: (val) { | |
setState(() { | |
_isChecked = val; | |
}); | |
}, | |
), | |
], | |
), | |
)), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment