Refactor _isMobile function in image_video_utils

pull/324/head
Xin Yao 4 years ago
parent 8aec946674
commit 352573211d
  1. 6
      lib/src/widgets/toolbar/image_video_utils.dart

@ -60,7 +60,7 @@ class ImageVideoUtils {
'Please provide webImagePickImpl for Web '
'(check out example directory for how to do it)');
imageUrl = await webImagePickImpl!(onImagePickCallback);
} else if (Platform.isAndroid || Platform.isIOS) {
} else if (_isMobile()) {
imageUrl = await _pickImage(imageSource, onImagePickCallback);
} else {
assert(filePickImpl != null, 'Desktop must provide filePickImpl');
@ -112,7 +112,7 @@ class ImageVideoUtils {
'Please provide webVideoPickImpl for Web '
'(check out example directory for how to do it)');
videoUrl = await webVideoPickImpl!(onVideoPickCallback);
} else if (Platform.isAndroid || Platform.isIOS) {
} else if (_isMobile()) {
videoUrl = await _pickVideo(videoSource, onVideoPickCallback);
} else {
assert(filePickImpl != null, 'Desktop must provide filePickImpl');
@ -125,6 +125,8 @@ class ImageVideoUtils {
}
}
static bool _isMobile() => Platform.isAndroid || Platform.isIOS;
static Future<String?> _pickVideo(
ImageSource source, OnVideoPickCallback onVideoPickCallback) async {
final pickedFile = await ImagePicker().pickVideo(source: source);

Loading…
Cancel
Save