DISCOVER FLUTTER — WEEK #17

Create Layout For The Settings Screen In a Flash in Flutter

SwitchListTile Widget

Jelena Jovanoski
3 min readDec 22, 2020

--

Photo by Philipp Kämmerer on Unsplash

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…

--

--

Jelena Jovanoski

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.