checkAndRequestPermissions static method

Future<List<CamerAwesomePermission>?> checkAndRequestPermissions(
  1. bool saveGpsLocation
)

Implementation

static Future<List<CamerAwesomePermission>?> checkAndRequestPermissions(
    bool saveGpsLocation) async {
  try {
    if (Platform.isAndroid) {
      return CameraInterface()
          .requestPermissions(saveGpsLocation)
          .then((givenPermissions) {
        return givenPermissions
            .map((e) => CamerAwesomePermission.values
                .firstWhere((element) => element.name == e))
            .toList();
      });
    } else if (Platform.isIOS) {
      // TODO iOS Return only permissions that were given
      return CamerawesomePlugin.checkiOSPermissions()
          .then((givenPermissions) => CamerAwesomePermission.values);
    }
  } catch (e) {
    printLog("failed to check permissions here...");
    // ignore: avoid_print
    print(e);
  }
  return Future.value([]);
}