0

I am new to flutter development. I wanted to achieve android onResume() functionality in flutter. I was handling that using then() like this

Navigator.push(context,
    MaterialPageRoute(builder: (_) => PageTwo()))
    .then((value) {
    refresh();
});

This is working fine If i am coming back from PageTwo to PageOne.

I am going to pageThree PageOne->pageTwo using Push() and pageTwo->PageThree using PushReplacement(). When i pop() pageThree pageOne is not refreshing.

Vignesh KM
  • 1,979
  • 1
  • 18
  • 24

1 Answers1

-1

Call the same then() when you call pushReplacement() to PageThree

Navigator.pushReplacement(
  context,
  MaterialPageRoute(builder: (_) => PageThree()))
.then((_) => refresh());
Michael Yuwono
  • 2,452
  • 1
  • 14
  • 32
  • refresh method is not available on PageTwo class – Vignesh KM May 19 '19 at 15:29
  • 1
    In that case, you may need to subscribe a Route Observer on the root widget to call `refresh()` whenever the current top route is `PageOne`. See https://api.flutter.dev/flutter/widgets/RouteObserver-class.html – Michael Yuwono May 19 '19 at 23:08