Home > database >  The return type 'Future<Object?>' isn't a 'void', as required by the
The return type 'Future<Object?>' isn't a 'void', as required by the

Time:04-12

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

CodePudding user response:

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);
  }

CodePudding user response:

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

Navigator.pushName(context,"YourRouteName");
  • Related