user13408251
user13408251

Reputation:

The argument type 'Future<bool>' can't be assigned to the parameter type 'Future<bool> Function()?'

i need to program the back arrow on the device, but this error occurs.

the code of WillPopScope: body: WillPopScope( onWillPop: back(context), => error ),

back function is:

Future<bool> back(BuildContext context) async {
    Navigator.of(context).pop();
    return true;
  }

Upvotes: 0

Views: 228

Answers (2)

Ravindra S. Patil
Ravindra S. Patil

Reputation: 14885

As per your requirnment you will click on back arrow and go to the previous screen so try below code hope it help to you.

IconButton(
      icon: Icon(Icons.arrow_back),
      onPressed: () => Navigator.pop(context, false),
    ),

Upvotes: 0

Hemal Moradiya
Hemal Moradiya

Reputation: 2077

change

 onWillPop: back(context),

to

onWillPop: () async => await back(context),

Upvotes: 1

Related Questions