Pushap
Pushap

Reputation: 31

The return type 'Future<Object?>' isn't a 'void', as required by the closure's context

I'm receiving this error. Can someone please help me :) ps: I'm new to flutter enter image description here

Upvotes: 1

Views: 3392

Answers (2)

Vishal_VE
Vishal_VE

Reputation: 2127

There is no need to add return at the time of navigation. just call-

Navigator.pushName(context,"YourRouteName");

Upvotes: 2

Paulo Oyama
Paulo Oyama

Reputation: 71

You don't need the "return" statement because "onTap" it's a void function, so it doesn't require a "return", you code might work if you only delete this "return". Furthermore, when you call "pushNamed" from Navigator, it returns a Future, but you don't actually need to take the value from it.

It may help later if you take a peek on Flutter's documentation.

 onTap(){
   if(doc!["subCat"] == null)
       Navigator.pushNamed(context, SellerBookForm.id);
  }

Upvotes: 4

Related Questions