fix: fix not asking for permission

This commit is contained in:
Aunali321 2023-06-12 09:56:49 +05:30
parent da0d88d86f
commit 13b7179941
2 changed files with 15 additions and 1 deletions

View File

@ -18,6 +18,8 @@ class NavigationViewModel extends IndexTrackingViewModel {
Future<void> initialize(BuildContext context) async {
locator<Toast>().initialize(context);
final SharedPreferences prefs = await SharedPreferences.getInstance();
requestManageExternalStorage();
if (prefs.getBool('permissionsRequested') == null) {
await Permission.storage.request();
await Permission.manageExternalStorage.request();
@ -28,6 +30,7 @@ class NavigationViewModel extends IndexTrackingViewModel {
),
);
}
if (prefs.getBool('useDarkTheme') == null) {
final bool isDark =
MediaQuery.of(context).platformBrightness != Brightness.light;
@ -46,6 +49,17 @@ class NavigationViewModel extends IndexTrackingViewModel {
);
}
Future<void> requestManageExternalStorage() async {
final manageExternalStorageStatus =
await Permission.manageExternalStorage.status;
if (manageExternalStorageStatus.isDenied) {
await Permission.manageExternalStorage.request();
}
if (manageExternalStorageStatus.isPermanentlyDenied) {
await openAppSettings();
}
}
Widget getViewForIndex(int index) {
switch (index) {
case 0:

View File

@ -4,7 +4,7 @@ homepage: https://github.com/revanced/revanced-manager
publish_to: 'none'
version: 1.3.4+100300004
version: 1.3.5+100300005
environment:
sdk: '>=3.0.0 <4.0.0'