Device Controls

Loading preview

Starting the Flutter app

A Flutter IoT device controls screen with toggle cards for lights, plugs, and sensors.

Get the source

Add it to your project

Copies the Dart source into your app, so you own it. Flutter SDK only, no extra packages.

First time? Run dart pub global activate fluttertemplates_dev, or read the CLI guide.

How it works

_toggles is a name-to-bool map that drives a SwitchListTile per device; icons are picked by comparing the key to 'Lamp' and 'Fan'. _SliderCard is reused for _brightness and _fanSpeed, showing each 0 to 1 value as a percentage. Nothing links the controls: turning off the lamp leaves its slider active, and no device is contacted.

Adapting it

  • Send commands to your hub from the onChanged callbacks, and debounce the sliders with onChangeEnd on Slider.
  • Move _toggles to a device model that holds its own icon, removing the string comparison.
  • Pass a null onChanged to _SliderCard when its device is off.