gurleensethi / sailor

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

How to return login page after logout #57

Closed NTMS2017 closed 3 years ago

NTMS2017 commented 3 years ago

Hi,

I have login page and after user successfully logged in it redirects to home page. User Interaction is 10 min. Meaning if user not interact with app 10 min. it redirects to login page.

But after redirects the login page the login page textfield and login button is not working. Any idea?

PS: Also I want to remove all other pages after login. I want to remove every page from stack from home page and home page onward. As shown below when app try to redirects from logout anything in stack from Home Page to Payment Page must be remove.

- Main Screen
- Login Page
- Home Page
- Account Page
     - Account Summary
     - Account Edit
     - Account View
- Card Page
     - Card Summary
     - Card Edit
     - Card View
- Payment Page
     - Payment Summary
     - Make Payment
- Logout Page

My Routes Class:

class Routes {
  static final sailor = Sailor(
    options: SailorOptions(
      handleNameNotFoundUI: true,
      isLoggingEnabled: true,
      customTransition: MyCustomTransition(),
      defaultTransitions: [
        SailorTransition.slide_from_bottom,
        SailorTransition.zoom_in,
      ],
      defaultTransitionCurve: Curves.decelerate,
      defaultTransitionDuration: Duration(milliseconds: 500),
    ),
  );

  /// ROUTES
  static void createRoutes() {
    sailor.addRoutes(
      [
        SailorRoute(
          name: "/LOGIN_PAGE",
          builder: (context, args, params) => LoginPage(),
        ),
        SailorRoute(
          name: "/HOME_PAGE",
          builder: (context, args, params) => HomePage(),
        ),

       .....
       .....
       .....
       .....
       .....

User Login Button:

 InkWell(
            splashColor: yellowColor,
            onTap: () {
              Routes.sailor.navigate("/HOME_PAGE"); 
            },

My Logout function:

  Future<void> _navigationToLoginPage() async {
    await Future.delayed(Duration.zero, () async {
      Routes.sailor.pop(true);
      await Routes.sailor.navigate("/LOGIN_PAGE");
    });
  }