import 'package:e2ee_chat/network/api.dart'; import 'profile.dart'; class UserModel extends ProfileChangeNotifier { bool get isLogin => profile.isLogin; _login(String token) { profile.token = token; profile.isLogin = true; notifyListeners(); } Future login({String? username, String? password}) async { String? token; if (username != null && password != null) { token = await Api().login(username: username, password: password); } else if (!profile.isLogin && profile.username != null) { if (profile.token != null) { token = await Api().login(username: profile.username!, token: profile.token); } } if (token != null) { _login(token); } } Future logout() async { if (profile.isLogin) { // TODO: logout } return false; } }