pickVideo method
Records a video from camera or gallery. Requires ImageSelectFeatureConfig.video with VideoFeatureConfig.enabled.
Not supported on web (depends on dart:io + native compressors).
Implementation
Future<File?> pickVideo({
required ImageFrom source,
}) async {
final v = features?.video;
if (v == null || !v.enabled) {
debugPrint('Video picking disabled: set ImageSelectFeatureConfig.video');
return null;
}
if (kIsWeb) {
debugPrint('pickVideo is not supported on web in this package.');
return null;
}
try {
final x = await _picker.pickVideo(
source: source == ImageFrom.camera ? ImageSource.camera : ImageSource.gallery,
maxDuration: v.maxDuration,
);
if (x == null) {
videoFile = null;
return null;
}
var f = File(x.path);
if (v.compressAfterPick) {
final info = await VideoCompress.compressVideo(
f.path,
quality: v.quality,
deleteOrigin: v.deleteOriginAfterCompress,
);
if (info?.path != null) {
f = File(info!.path!);
}
}
videoFile = f;
return f;
} catch (e, st) {
debugPrint('Error picking/compressing video: $e\n$st');
return null;
}
}