Search code examples
flutternullflutter-widget

The argument type 'Null' can't be assigned to the parameter type 'String'. Flutter Issue


  @override
  Widget? buildLeading(BuildContext context) {
    return IconButton(
      icon: AnimatedIcon(
        icon: AnimatedIcons.menu_arrow,
        progress: transitionAnimation,
      ),
      onPressed: () {
        close(context, null);
      },
    );
  }

Null is causing the trouble

Pls solve this flutter issue as soon as possible


Solution

  • It's happening because of the flutter null safety feature try this,

    onPressed: () {
                     close(context, '');
                  },
    

    pass the empty string, because of the flutter null safety you can not assign null values.