flutteronpress

What to do If I can't assign Future functions to onPressed in flutter?


I have a proplem in assigning a sign in future method to onpressed :The argument type 'Future' can't be assigned to the parameter type 'void Function()'.


Solution

  • you have to assign it like this:

    onpressed: () => FunctionName()
    

    Because the handler expects a function with no return. So we just call your function inside an anonymous void function.