mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2026-01-25 12:01:02 +00:00
fix: code refactoring (#5)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user