-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #370 from Shubham04Jha/loading
loading screen bug fixed, by giving permissions
- Loading branch information
Showing
6 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:permission_handler/permission_handler.dart'; | ||
|
||
List<Permission> permissions = [ | ||
Permission.notification, | ||
Permission.storage, | ||
Permission.manageExternalStorage, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// ignore_for_file: avoid_print | ||
|
||
import 'package:permission_handler/permission_handler.dart'; | ||
import 'package:taskwarrior/app/utils/constants/permissions.dart'; | ||
|
||
class PermissionsManager { | ||
static Future<void> requestAllPermissions() async { | ||
try { | ||
for (var permission in permissions) { | ||
final status = await _requestPermission(permission); | ||
|
||
if (status) { | ||
print("Permission '${permission.toString().split('.').last}' granted."); | ||
} else { | ||
print("Permission '${permission.toString().split('.').last}' denied."); | ||
} | ||
} | ||
} catch (e) { | ||
print("Error requesting permissions: $e"); | ||
} | ||
} | ||
|
||
static Future<bool> _requestPermission(Permission permission) async { | ||
final status = await permission.request(); | ||
return status.isGranted; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters