file_picker_service.dart 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import 'package:file_picker/file_picker.dart';
  2. class FilePickerResult {
  3. const FilePickerResult(this.files);
  4. /// Picked files.
  5. final List<PlatformFile> files;
  6. }
  7. /// Abstract file picker as a service to implement dependency injection.
  8. abstract class FilePickerService {
  9. Future<String?> getDirectoryPath({
  10. String? title,
  11. }) async =>
  12. throw UnimplementedError('getDirectoryPath() has not been implemented.');
  13. Future<FilePickerResult?> pickFiles({
  14. String? dialogTitle,
  15. String? initialDirectory,
  16. FileType type = FileType.any,
  17. List<String>? allowedExtensions,
  18. Function(FilePickerStatus)? onFileLoading,
  19. bool allowCompression = true,
  20. bool allowMultiple = false,
  21. bool withData = false,
  22. bool withReadStream = false,
  23. bool lockParentWindow = false,
  24. }) async =>
  25. throw UnimplementedError('pickFiles() has not been implemented.');
  26. Future<String?> saveFile({
  27. String? dialogTitle,
  28. String? fileName,
  29. String? initialDirectory,
  30. FileType type = FileType.any,
  31. List<String>? allowedExtensions,
  32. bool lockParentWindow = false,
  33. }) async =>
  34. throw UnimplementedError('saveFile() has not been implemented.');
  35. }