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);

    });
  }
}