Project lint checked and step added to config.yml

This commit is contained in:
2022-10-02 17:43:52 +01:00
parent e07e10079e
commit 8100f0b879
26 changed files with 71 additions and 63 deletions

32
lib/base_viewmodel.dart Normal file
View File

@@ -0,0 +1,32 @@
import 'package:stacked/stacked.dart';
import 'Utils/view_state.dart';
abstract class BaseViewmodel extends BaseViewModel{
ViewState _viewState = Idle();
ViewState get viewState => _viewState;
void onStart() {
_viewState = HasStarted();
notifyListeners();
}
void onSuccess(dynamic data) {
_viewState = HasData(data);
notifyListeners();
}
void onError(String error) {
_viewState = HasError(error);
notifyListeners();
}
dynamic getData() {
if (viewState.runtimeType is HasData) {
return (viewState as HasData).data;
} else {
return null;
}
}
}