fix: set isRooted state at RootCheckerView init

This commit is contained in:
Alberto Ponces 2022-09-05 09:14:56 +01:00
parent db02dc623f
commit 5e8e090e34
2 changed files with 5 additions and 0 deletions

View File

@ -11,6 +11,7 @@ class RootCheckerView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ViewModelBuilder<RootCheckerViewModel>.reactive(
onModelReady: (model) => model.initialize(),
viewModelBuilder: () => RootCheckerViewModel(),
builder: (context, model, child) => Scaffold(
floatingActionButton: FloatingActionButton.extended(

View File

@ -10,6 +10,10 @@ class RootCheckerViewModel extends BaseViewModel {
final ManagerAPI _managerAPI = locator<ManagerAPI>();
bool isRooted = false;
void initialize() {
isRooted = _managerAPI.isRooted() ?? false;
}
Future<void> navigateAsRoot() async {
bool? res = await Root.isRooted();
isRooted = res != null && res == true;