How to call a provider as well as navigate to other page by pressing/tapping a button in Flutter..?

Viewed 107

I want to call a provider as well as navigate to another page simultaneously by pressing/tapping a button in Flutter?

Is this possible?

More specifically what I want is when I press the button the current Navigator should pop() out and meanwhile call a provider too.

1 Answers

Yes, it is possible. I assume that you are managing the CircularProgressIndicator in your provider. You can set it onPress method of your button like this:

      onPress: () {
          _appStateProvider.setLoading(true); 
          Navigator.pop(context);
Related