import 'package:flutter/cupertino.dart'; import 'package:sampleapp/services/auth/auth.dart'; class AuthViewModel extends ChangeNotifier { final AuthService authService; bool loggingIn = false; bool loggingOut = false; AuthViewModel(this.authService); Future login() { return Future.delayed(Duration.zero, () async { loggingIn = true; notifyListeners(); await authService.login(); loggingIn = false; notifyListeners(); return authService.isLoggedIn(); }); } Future logout() async { loggingOut = true; notifyListeners(); await authService.logout(); loggingOut = false; notifyListeners(); return !(await authService.isLoggedIn()); } }