Answers for "'Function' can't be assigned to the parameter type 'void Function()?"

0

'Function' can't be assigned to the parameter type 'void Function()?

class DrawerItem extends StatelessWidget {
    
      final String text;
      final VoidCallback onPressed;
    
      const DrawerItem({Key key, this.text, this.onPressed}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return FlatButton(
          child: Text(
            text,
            style: TextStyle(
              fontWeight: FontWeight.w600,
              fontSize: 18.0,
            ),
          ),
          onPressed: onPressed,
        );
      }
    }
Posted by: Guest on March-08-2022

Code answers related to "'Function' can't be assigned to the parameter type 'void Function()?"

Browse Popular Code Answers by Language