stopVideoRecording method

Future<File?> stopVideoRecording()

Implementation

Future<File?> stopVideoRecording() async {
  if (!widget._controller.cameraController!.value.isRecordingVideo) {
    return null;
  }

  try {
    XFile file =
        await widget._controller.cameraController!.stopVideoRecording();
    timer = null;
    setState(() {
      isRecording = false;
      seconds = 0;
    });

    final bytes = kIsWeb ? await file.readAsBytes() : null;
    final fileSize = await file.length();
    return File(
        file.name, file.path.split('.').last, fileSize, file.path, bytes);
  } on CameraException catch (_) {
    return null;
  }
}