claude refactorings, flutter best practices, platform dependent changes, general cleanup
This commit is contained in:
@@ -1,29 +1,19 @@
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class FilePick {
|
||||
static final _picker = ImagePicker();
|
||||
|
||||
static Future<XFile?> galleryPick() async {
|
||||
final pickedImage = await _picker.pickImage(source: ImageSource.gallery);
|
||||
if (pickedImage != null) {
|
||||
return pickedImage;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<List<XFile>?> multipleGalleryPick() async {
|
||||
final pickedImages = await _picker.pickMultiImage();
|
||||
if(pickedImages.isNotEmpty) {
|
||||
return pickedImages;
|
||||
}
|
||||
return null;
|
||||
return pickedImages.isNotEmpty ? pickedImages : null;
|
||||
}
|
||||
|
||||
static Future<XFile?> cameraPick() => _picker.pickImage(source: ImageSource.camera);
|
||||
|
||||
static Future<List<String>?> documentPick() async {
|
||||
var result = await FilePicker.platform.pickFiles(allowMultiple: true);
|
||||
var paths = result?.files.nonNulls.map((e) => e.path).toList();
|
||||
final result = await FilePicker.pickFiles(allowMultiple: true);
|
||||
final paths = result?.files.nonNulls.map((e) => e.path).toList();
|
||||
return paths?.nonNulls.toList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user