From c876f2f7e349bcc0189fa46d8470c6325abd313b Mon Sep 17 00:00:00 2001 From: Aunali321 Date: Mon, 12 Jun 2023 08:59:14 +0530 Subject: [PATCH] feat: add permission to manage storage --- android/app/src/main/AndroidManifest.xml | 2 ++ lib/ui/views/navigation/navigation_viewmodel.dart | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 3df4d3af..e8307c84 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -6,6 +6,8 @@ + + diff --git a/lib/ui/views/navigation/navigation_viewmodel.dart b/lib/ui/views/navigation/navigation_viewmodel.dart index 4ca900c3..58ae74c1 100644 --- a/lib/ui/views/navigation/navigation_viewmodel.dart +++ b/lib/ui/views/navigation/navigation_viewmodel.dart @@ -17,14 +17,14 @@ import 'package:stacked/stacked.dart'; class NavigationViewModel extends IndexTrackingViewModel { Future initialize(BuildContext context) async { locator().initialize(context); - final SharedPreferences prefs = - await SharedPreferences.getInstance(); + final SharedPreferences prefs = await SharedPreferences.getInstance(); if (prefs.getBool('permissionsRequested') == null) { + await Permission.storage.request(); + await Permission.manageExternalStorage.request(); await prefs.setBool('permissionsRequested', true); RootAPI().hasRootPermissions().then( (value) => Permission.requestInstallPackages.request().then( - (value) => - Permission.ignoreBatteryOptimizations.request(), + (value) => Permission.ignoreBatteryOptimizations.request(), ), ); } @@ -39,8 +39,7 @@ class NavigationViewModel extends IndexTrackingViewModel { SystemUiOverlayStyle( systemNavigationBarColor: Colors.transparent, systemNavigationBarIconBrightness: - DynamicTheme.of(context)!.theme.brightness == - Brightness.light + DynamicTheme.of(context)!.theme.brightness == Brightness.light ? Brightness.dark : Brightness.light, ),