settingSwitch function

Widget settingSwitch(
  1. dynamic item,
  2. Function setState,
  3. String parent,
  4. String setting
)

Implementation

Widget settingSwitch(item, Function setState, String parent, String setting) {
  final name = setting.uppercaseFirst();
  return Padding(
    padding: const EdgeInsets.all(8.0),
    child: Row(
      children: [
        ToggleSwitch(
          checked: prefs.getBool('$item-$setting') ?? false,
          onChanged: (value) {
            prefs.setBool('$item-$setting', value);
            setState(() {});
            // Execute command in WSL
            WSLApi().setSetting(item, parent, setting, value.toString());
          },
        ),
        const SizedBox(
          width: 8.0,
        ),
        Text(name),
      ],
    ),
  );
}