31 lines
732 B
Dart
31 lines
732 B
Dart
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<bool> login() {
|
|
return Future.delayed(Duration.zero, () async {
|
|
loggingIn = true;
|
|
notifyListeners();
|
|
await authService.login();
|
|
loggingIn = false;
|
|
notifyListeners();
|
|
return authService.isLoggedIn();
|
|
});
|
|
}
|
|
|
|
Future<bool> logout() async {
|
|
loggingOut = true;
|
|
notifyListeners();
|
|
await authService.logout();
|
|
loggingOut = false;
|
|
notifyListeners();
|
|
return !(await authService.isLoggedIn());
|
|
}
|
|
}
|