checkAndRequestPermissions static method
Implementation
static Future<List<CamerAwesomePermission>?> checkAndRequestPermissions(
bool saveGpsLocation, {
bool checkMicrophonePermissions = true,
bool checkCameraPermissions = true,
}) 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
List<String> permissions = [];
if (checkMicrophonePermissions) {
permissions.add("microphone");
}
if (checkCameraPermissions) {
permissions.add("camera");
}
return CamerawesomePlugin.checkiOSPermissions(permissions)
.then((givenPermissions) => CamerAwesomePermission.values);
}
} catch (e) {
printLog("failed to check permissions here...");
// ignore: avoid_print
print(e);
}
return Future.value([]);
}