firset commit
This commit is contained in:
46
lib/common/base/ui_model.dart
Normal file
46
lib/common/base/ui_model.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BaseUIModel with ChangeNotifier {
|
||||
static Function? staticNotifyListeners;
|
||||
BuildContext? context;
|
||||
bool showProgressHUD = false;
|
||||
|
||||
bool initialPage = true;
|
||||
|
||||
/// 判断页面是否被销毁
|
||||
bool disposed = false;
|
||||
|
||||
dismissKeyboard(BuildContext? context) {
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
}
|
||||
|
||||
showLoadingHud() {
|
||||
showProgressHUD = true;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
dismissLoadingHud() {
|
||||
showProgressHUD = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
void notifyListeners() {
|
||||
if (!hasListeners) {
|
||||
return;
|
||||
}
|
||||
if (disposed) {
|
||||
return;
|
||||
}
|
||||
super.notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
disposed = true;
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user