Skip to content

The fromModular flag is not working properly. #454

@Nanow

Description

@Nanow

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:

/// The `fromModular` flag prevents all pages in `_pages` from being replaced
/// when navigating with the browser's back button
///
_lastPageModule.completePop(null);
removeInject(_lastPageModule.router.path!);
for (var r in _lastPageModule.router.routerOutlet) {
removeInject(r.path!);
}
_pages.remove(_lastPageModule);
_pages.add(page);
}
}

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;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions