modular icon indicating copy to clipboard operation
modular copied to clipboard

The fromModular flag is not working properly.

Open Nanow opened this issue 5 years ago • 1 comments

During browsing, the times when fromModular is being set to true are when iterations occur through devTools via the select widget mode, or the back or forward button in the browser is pressed.

The currentConfiguration method is responsible for setting the browser's history, and if it is overwritten, it is the one who maintains the information to rebuild paths and make the setRestoredRoutePath work.

To prevent all pages from being overwritten on the web, setRestoredRoutePath needs to be implemented.

One simple solution is to remove this part of the code:

https://github.com/Flutterando/modular/blob/9e195cc143773336b983396163c6ad56758eec7e/flutter_modular/lib/src/presenters/navigation/modular_router_delegate.dart#L124-L137

Another one is to make the currentConfiguration to return null if the code is in Web mode, but this method will prevent the browser to keep the navigation history and the back and foward keys work.

@override
  ModularRoute? get currentConfiguration {
     if (kIsWeb) {
       return null;
     }
    return _pages.isEmpty ? null : _pages.last.router;
  }

Nanow avatar Jun 14 '21 21:06 Nanow

Issue fixed in #456

Nanow avatar Jun 18 '21 11:06 Nanow