takePhoto method

Future<String> takePhoto()

Photos taken are in JPEG format. filePath must end with .jpg

You can listen to cameraSetup.mediaCaptureStream to get updates of the photo capture (capturing, success/failure)

Implementation

Future<String> takePhoto() async {
  String path = await filePathBuilder();
  if (!path.endsWith(".jpg")) {
    throw ("You can only capture .jpg files with CamerAwesome");
  }
  _mediaCapture = MediaCapture.capturing(filePath: path);
  try {
    final succeeded = await CamerawesomePlugin.takePhoto(path);
    if (succeeded) {
      await FilterHandler().apply(path: path, filter: filter);
      _mediaCapture = MediaCapture.success(filePath: path);
    } else {
      _mediaCapture = MediaCapture.failure(filePath: path);
    }
  } on Exception catch (e) {
    _mediaCapture = MediaCapture.failure(filePath: path, exception: e);
  }
  return path;
}