capturedFile method

Future<File?> capturedFile({
  1. bool? allowRecord,
})

Opens the camera screen and returns the captured file path.

Navigates to the CameraScreen and waits for a file to be captured. Returns the file path if successful, otherwise returns null.

Implementation

Future<File?> capturedFile({bool? allowRecord}) async {
  File? capturedPath;
  await Navigator.push(
    context,
    MaterialPageRoute(
        builder: (context) => CameraScreen(
              allowRecord: allowRecord ?? false,
            )),
  ).then((path) {
    if (path != null) {
      capturedPath = File(path);
    }
  }).catchError((e) {
    capturedPath = null;
  });

  return capturedPath;
}