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

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.

Answered By – Akshay Kaneriya

Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *