Flutter provider state management, logout concept

前端 未结 2 1622
Happy的楠姐
Happy的楠姐 2020-12-19 11:29

I am trying to implement custom logout solution for my application, where no matter where user currently is, once the Logout button is clicked, app will navigat

2条回答
  •  抹茶落季
    2020-12-19 12:16

    You don't need to pass listen:false, instead simply call

    Provider.of(context).logout()

    So your Profile class would look like

          class Profile with ChangeNotifier {
      bool isAuthentificated = false;
    
    
      logout() {
        isAuthentificated = false;
        notifyListeners();
      }
    }
    

提交回复
热议问题