You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			30 lines
		
	
	
		
			697 B
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			30 lines
		
	
	
		
			697 B
		
	
	
	
		
			Dart
		
	
import 'package:permission_handler/permission_handler.dart';
 | 
						|
 | 
						|
class AppPermissions{
 | 
						|
  static void location(Function(bool) completion) {
 | 
						|
    Permission.location.isGranted.then((isGranted){
 | 
						|
      if(!isGranted){
 | 
						|
        Permission.location.request().then((granted){
 | 
						|
          completion(granted == PermissionStatus.granted);
 | 
						|
        });
 | 
						|
      }
 | 
						|
      completion(isGranted);
 | 
						|
    });
 | 
						|
 | 
						|
  }
 | 
						|
 | 
						|
  static void checkAll(Function(bool) completion){
 | 
						|
    [
 | 
						|
      Permission.location
 | 
						|
    ].request().then((value){
 | 
						|
 | 
						|
      bool allGranted = false;
 | 
						|
      value.values.forEach((element) {
 | 
						|
        allGranted = allGranted && element == PermissionStatus.granted;
 | 
						|
      });
 | 
						|
 | 
						|
      completion(allGranted);
 | 
						|
 | 
						|
    });
 | 
						|
  }
 | 
						|
} |