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

Loading…
Cancel
Save