gurleensethi / sailor

Easy page navigation and management in Flutter apps.
https://pub.dev/packages/sailor
MIT License
145 stars 24 forks source link

Feature/route guard redirect #31

Closed CasperPas closed 4 years ago

CasperPas commented 4 years ago

Implementation for redirect feature mention at https://github.com/gurleensethi/sailor/issues/28

This PR included commits from these PRs:

Example

SailorRoute(
  name: 'user_info',
  builder: (context, args, params) => UserInfoPage(),
  routeGuards: [
    SailorRouteGuard.simple((context, args, params) async {
      if (userBloc.isLoggedIn) {
        return true;
      } else {
        // Redirect to login page
        return RouteArgsPair('/login');
      }
    }),
  ],
),
gurleensethi commented 4 years ago

Thanks for the PR. Appreciate the community's efforts to improve Sailor. While this does solve the problem, its not the ideal solution. I will be updating the library in coming days, it will be a major refactor and will provide a way where it will allow for redirects.

rlee1990 commented 4 years ago

@gurleensethi are there any updates on when this will be released?