Files
qinglong_app/lib/base/base_viewmodel.dart
2022-01-12 15:45:52 +08:00

46 lines
763 B
Dart

import 'package:flutter/cupertino.dart';
class ViewModel extends ChangeNotifier{}
class BaseViewModel extends ViewModel {
PageState currentState = PageState.START;
void loading({bool notify = false}) {
currentState = PageState.LOADING;
if (notify) {
notifyListeners();
}
}
void success({bool notify = true}) {
currentState = PageState.CONTENT;
if (notify) {
notifyListeners();
}
}
void failed({bool notify = false}) {
currentState = PageState.FAILED;
if (notify) {
notifyListeners();
}
}
void empty({bool notify = false}) {
currentState = PageState.EMPTY;
if (notify) {
notifyListeners();
}
}
}
enum PageState {
START,
LOADING,
EMPTY,
CONTENT,
FAILED,
}