DISCOVER FLUTTER — WEEK #17

Create Layout For The Settings Screen In a Flash in Flutter

Image for post
Image for post
Photo by Philipp Kämmerer on Unsplash

SwitchListTile in a few words

SwitchListTile in Example

SwitchListTile(
title: Text('Airplane Mode'),
secondary: Icon(Icons.airplanemode_active),
onChanged: (value) {
setState(() {
_toggleAirplaneMode = value;
});
},
value: _toggleAirplaneMode,
)
Image for post
Image for post
class _MyHomePageState extends State<MyHomePage> {
bool _toggleAirplaneMode = false;
bool _toggleBluetooth = false;
bool _toggleWiFi = false;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
children: [
SwitchListTile(
title: Text('Airplane Mode'),
secondary: Icon(Icons.airplanemode_active),
onChanged: (value) {
setState(() {
_toggleAirplaneMode = value;
});
},
value: _toggleAirplaneMode,
),
Divider(
thickness: 1.2,
),
SwitchListTile(
title: Text('Wi-Fi'),
secondary: Icon(Icons.wifi),
onChanged: (value) {
setState(() {
_toggleWiFi = value;
});
},
value: _toggleWiFi,
),
Divider(
thickness: 1.2,
),
SwitchListTile(
title: Text('Bluetooth'),
secondary: Icon(Icons.bluetooth),
onChanged: (value) {
setState(() {
_toggleBluetooth = value;
});
},
value: _toggleBluetooth,
),
],
)) // This trailing comma makes auto-formatting nicer for build methods.
);
}
}

Conclusion

On my journey to become a Flutter dev I will be sharing knowledge by writing short texts about what new know-how’s I’ve learned, in the next 30 weeks.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store