fix: code refactoring (#5)

This commit is contained in:
Alberto Ponces
2022-08-18 15:33:33 +01:00
committed by GitHub
parent 6153e1f9e8
commit 389eae1447
31 changed files with 318 additions and 361 deletions

View File

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

View File

@@ -6,12 +6,13 @@ import 'package:root/root.dart';
import 'package:stacked_services/stacked_services.dart';
class RootCheckerViewModel extends BaseViewModel {
final _navigationService = locator<NavigationService>();
bool? isRooted = false;
final NavigationService _navigationService = locator<NavigationService>();
bool isRooted = false;
Future<void> checkRoot() async {
isRooted = await Root.isRooted();
if (isRooted == true) {
bool? res = await Root.isRooted();
isRooted = res != null && res == true;
if (isRooted) {
navigateToHome();
}
notifyListeners();
@@ -19,7 +20,7 @@ class RootCheckerViewModel extends BaseViewModel {
Future<void> navigateToHome() async {
final prefs = await SharedPreferences.getInstance();
prefs.setBool('isRooted', isRooted!);
prefs.setBool('isRooted', isRooted);
_navigationService.navigateTo(Routes.navigation);
notifyListeners();
}