Zubair Zahoor
Zubair Zahoor

Reputation: 121

How to update widgets when a route resumes?

Is there any equivalent for Android Acyivity's "onResume" in flutter? I want to refresh a widget in a previous route when Navigator pops a route and comes back to previous route. WidgetBingingObserver only works when app is resumed from background not when a route is resumed.

Upvotes: 2

Views: 1242

Answers (1)

Dinesh Balasubramanian
Dinesh Balasubramanian

Reputation: 21758

When you push to new page, you will get the Future which will get resolved on pop.

 var future = Navigator.push(
          context,
          MaterialPageRoute(builder: (context) => SecondScreen()),
        );
 future.then((value) {
         print(value);
         print("popeed");
        });

You can send values from nextPage like (It is optional, if you are not sending it will be null while resolving future)

Navigator.pop(context, 2);

Upvotes: 2

Related Questions