pickVideoFromGallery method

Future<File?> pickVideoFromGallery({
  1. double? maxDuration,
})

Implementation

Future<File?> pickVideoFromGallery({
  double? maxDuration,
}) async {
  bool hasPermission = await _checkGalleryPermission();
  if (!hasPermission) return null;

  try {
    final XFile? video = await _picker.pickVideo(
      source: ImageSource.gallery,
      maxDuration:
          maxDuration != null ? Duration(seconds: maxDuration.toInt()) : null,
    );

    if (video != null) {
      return File(video.path);
    }
  } catch (e) {
    print('Error picking gallery video: $e');
  }
  return null;
}