-1
 Widget _buildSwitchListTile(
     String title,
     String description,
      bool currentValue, 
      VoidCallback updateValue) {
    return SwitchListTile(
      value: currentValue,
      title: Text(title),
      subtitle: Text(description),
      onChanged: updateValue,
    );
  
Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56

2 Answers2

0

You can use this:

final void Function()? onTap;

and if you want, that function passed some data, you can use it like this:

final void Function(bool)? onTap;

aminjafari-dev
  • 264
  • 1
  • 17
0

SwitchListTile onChanged provide a nullable bool on callback. Try changing Function(bool) updateValue

 Widget _buildSwitchListTile(
     String title,
     String description,
      bool currentValue, 
      Function(bool) updateValue) {
    return SwitchListTile(
      value: currentValue,
      title: Text(title),
      subtitle: Text(description),
      onChanged: updateValue,
    );
  
Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
  • glad to help, you can check more about [understanding-null-safety](https://dart.dev/null-safety/understanding-null-safety) and find more about [SwitchListTile](https://api.flutter.dev/flutter/material/SwitchListTile-class.html) – Md. Yeasin Sheikh Aug 09 '22 at 20:03