Commit 8639a1e1 authored by Sai Srinivas's avatar Sai Srinivas
Browse files

Contact permission fixed

parent 9fbbf730
...@@ -271,6 +271,7 @@ class _ContactListScreenState extends State<ContactListScreen> { ...@@ -271,6 +271,7 @@ class _ContactListScreenState extends State<ContactListScreen> {
// This will automatically take full height of the list item // This will automatically take full height of the list item
SlidableAction( SlidableAction(
onPressed: (_) async { onPressed: (_) async {
await _requestContactsPermission();
_addToContact( _addToContact(
contact.name ?? 'Contact', contact.name ?? 'Contact',
contact.mobileNumber ?? '', contact.mobileNumber ?? '',
...@@ -412,4 +413,18 @@ class _ContactListScreenState extends State<ContactListScreen> { ...@@ -412,4 +413,18 @@ class _ContactListScreenState extends State<ContactListScreen> {
), ),
); );
} }
Future<void> _requestContactsPermission() async {
final status = await Permission.contacts.status;
if (status.isPermanentlyDenied) {
// Show dialog and send user to settings
await openAppSettings();
return;
}
if (!status.isGranted) {
await Permission.contacts.request();
}
}
} }
\ No newline at end of file
...@@ -243,8 +243,24 @@ class _SplashState extends State<Splash> { ...@@ -243,8 +243,24 @@ class _SplashState extends State<Splash> {
await getCameraPermissions(); await getCameraPermissions();
await getStoragePermission(); await getStoragePermission();
await getLocationPermissions(); await getLocationPermissions();
await _requestContactsPermission();
} }
Future<void> _requestContactsPermission() async {
final status = await Permission.contacts.status;
if (status.isPermanentlyDenied) {
// Show dialog and send user to settings
await openAppSettings();
return;
}
if (!status.isGranted) {
await Permission.contacts.request();
}
}
Future<void> getStoragePermission() async { Future<void> getStoragePermission() async {
if (await Permission.manageExternalStorage.request().isGranted) { if (await Permission.manageExternalStorage.request().isGranted) {
print("Storage"); print("Storage");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment