Initial commit: imajViewer Flutter Linux image viewer
This commit is contained in:
commit
8369ec2a5d
33 files changed
+2165
No files matched your search
@@ -0,0 +1,28 @@
|
||||
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', 'webp', 'bmp', 'gif'],
|
||||
allowMultiple: true,
|
||||
);
|
||||
|
||||
if (result != null && result.files.isNotEmpty) {
|
||||
final paths = result.files
|
||||
.where((f) => f.path != null)
|
||||
.map((f) => f.path!)
|
||||
.toList();
|
||||
ImageManager.instance.addImages(paths);
|
||||
}
|
||||
}
|
||||
|
||||
/// Load images from given file paths
|
||||
static void loadImagesFromPaths(List<String> paths) {
|
||||
if (paths.isNotEmpty) {
|
||||
ImageManager.instance.addImages(paths);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user