Home > front end >  Is there a way to solve the BuildContext problem?
Is there a way to solve the BuildContext problem?

Time:12-06

Error Image

I'm getting The argument type BuildContext Function() can't be assigned to the parameter type BuildContext.

CodePudding user response:

You can't send context to a function when it isn't even defined in the initstate function. Here you are trying to use provider outside the Build Function which is a no no. What you can do as an alternative is to wrap the function with a Future to give it a valid context :

 WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
   myString = Provider.of<AppData>(context, listen: false).testString;
    });

CodePudding user response:

I solved this by removing the flutter whole folder where it is saved and than remove the Environmental Values and remove path and add new download new Flutter SDK and than again update the path in Environmental Values

  • Related