0

I am using the following method to call a loading dialog before going to the next screen , but when i return to the previous page with the App Bars back function the Loading indicator is still loading.

How do you clear all Navigators when going back?

showDialog(
      context: context,
      builder: (context) {
        return Center(
          child: CircularProgressIndicator(),
        );
      });
Sujan Gainju
  • 4,273
  • 2
  • 14
  • 34
Stephan
  • 1
  • 1

1 Answers1

1

Probably you call Navigator.of(context).pop(). Context is an interesting but also hard to well-understand in Flutter. Well, I could say this: EACH screen has it own context. But when you open modal bottom sheet & dialog, it creates another context. It's kinda confusing if you don't carefully notice (dev usually named every context variables is context). Therefore, when you tap on back button on app bar and call Navigator.of(context).pop(), it is context of the screen, not the dialog. You can follow the link: How to dismiss flutter dialog?

Nguyen family
  • 749
  • 2
  • 12