DISCOVER FLUTTER — WEEK #17
Create Layout For The Settings Screen In a Flash in Flutter
SwitchListTile Widget
Settings section exists in every app and taking into account the fact that people like one-click features, switch buttons are always a good option.
Usually, this screen contains a list of setting options. Since it is a list and we want to present it in the form of a toggle button, the widget that provides this in one go is the SwitchListTile
Widget.
SwitchListTile in a few words
SwitchListTile
is similar to other list tile widgets (CheckboxListTile
, RadioListTile
, because this widget is a ListTile
with a Switch
.
Compared to the ListTile
widget, it has two additional mandatory properties:
value
— boolean value that monitors the state of the button. It tells us whether this switch is checked. This property must not be null.onChanged
— This method is called when the user toggles the switch on or off. In this method, we change the state of the property that monitors the state of the toggle button (on/off = true/false)
If you want to add a leading icon that will specify the function of this button next to the title, you can use the property…