29 lines
841 B
Dart
29 lines
841 B
Dart
import 'package:file_picker/file_picker.dart';
|
|
import 'image_manager.dart';
|
|
|
|
class FileHandler {
|
|
/// Open file picker dialog and load images
|
|
static Future<void> openFileDialog() async {
|
|
final result = await FilePicker.platform.pickFiles(
|
|
type: FileType.custom,
|
|
allowedExtensions: ['png', 'jpg', 'jpeg', 'jfif', 'jpe', 'webp', 'bmp', 'gif', 'wbmp'],
|
|
allowMultiple: true,
|
|
);
|
|
|
|
if (result != null && result.files.isNotEmpty) {
|
|
final paths = result.files
|
|
.where((f) => f.path != null)
|
|
.map((f) => f.path!)
|
|
.toList();
|
|
ImageManager.instance.setGalleryFromPaths(paths);
|
|
}
|
|
}
|
|
|
|
/// Load images from given file paths
|
|
static void loadImagesFromPaths(List<String> paths) {
|
|
if (paths.isNotEmpty) {
|
|
ImageManager.instance.setGalleryFromPaths(paths);
|
|
}
|
|
}
|
|
}
|