You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aku_new_community/lib/provider/user_provider.dart

31 lines
658 B

4 years ago
import 'package:akuCommunity/utils/hive_store.dart';
import 'package:flutter/material.dart';
4 years ago
class UserProvider extends ChangeNotifier {
//登录状态管理
4 years ago
bool _isSigned = false;
get isSigned => _isSigned;
4 years ago
setisSigned(bool state) {
_isSigned = state;
notifyListeners();
}
4 years ago
bool _isLogin = false;
bool get isLogin => _isLogin;
setLogin(bool state, String token) {
_isLogin = state;
HiveStore.appBox.put('token', token);
notifyListeners();
}
logout() {
_isLogin = false;
_token = null;
HiveStore.appBox.delete('token');
notifyListeners();
}
String _token;
String get token => _token ?? '';
}