From 5e8e090e342b46edf48e46f9a292a0e17d69e18c Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Mon, 5 Sep 2022 09:14:56 +0100 Subject: [PATCH] fix: set isRooted state at RootCheckerView init --- lib/ui/views/root_checker/root_checker_view.dart | 1 + lib/ui/views/root_checker/root_checker_viewmodel.dart | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/ui/views/root_checker/root_checker_view.dart b/lib/ui/views/root_checker/root_checker_view.dart index 5559c5ee..4879848c 100644 --- a/lib/ui/views/root_checker/root_checker_view.dart +++ b/lib/ui/views/root_checker/root_checker_view.dart @@ -11,6 +11,7 @@ class RootCheckerView extends StatelessWidget { @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( + onModelReady: (model) => model.initialize(), viewModelBuilder: () => RootCheckerViewModel(), builder: (context, model, child) => Scaffold( floatingActionButton: FloatingActionButton.extended( diff --git a/lib/ui/views/root_checker/root_checker_viewmodel.dart b/lib/ui/views/root_checker/root_checker_viewmodel.dart index 55a97964..93684b70 100644 --- a/lib/ui/views/root_checker/root_checker_viewmodel.dart +++ b/lib/ui/views/root_checker/root_checker_viewmodel.dart @@ -10,6 +10,10 @@ class RootCheckerViewModel extends BaseViewModel { final ManagerAPI _managerAPI = locator(); bool isRooted = false; + void initialize() { + isRooted = _managerAPI.isRooted() ?? false; + } + Future navigateAsRoot() async { bool? res = await Root.isRooted(); isRooted = res != null && res == true;