diff --git a/packages/neon/neon/lib/src/platform/android.dart b/packages/neon/neon/lib/src/platform/android.dart index d4d905c5..9dceed83 100644 --- a/packages/neon/neon/lib/src/platform/android.dart +++ b/packages/neon/neon/lib/src/platform/android.dart @@ -31,6 +31,9 @@ class AndroidNeonPlatform implements NeonPlatform { @override bool get canUseSharing => true; + @override + bool get shouldUseFileDialog => true; + @override Future get userAccessibleAppDataPath async { if (!await Permission.storage.request().isGranted) { diff --git a/packages/neon/neon/lib/src/platform/linux.dart b/packages/neon/neon/lib/src/platform/linux.dart index 144f0072..4c3f5b2c 100644 --- a/packages/neon/neon/lib/src/platform/linux.dart +++ b/packages/neon/neon/lib/src/platform/linux.dart @@ -31,6 +31,9 @@ class LinuxNeonPlatform implements NeonPlatform { @override bool get canUseSharing => false; + @override + bool get shouldUseFileDialog => false; + @override String get userAccessibleAppDataPath => p.join(Platform.environment['HOME']!, 'Neon'); diff --git a/packages/neon/neon/lib/src/platform/platform.dart b/packages/neon/neon/lib/src/platform/platform.dart index 283be64f..6393ea2a 100644 --- a/packages/neon/neon/lib/src/platform/platform.dart +++ b/packages/neon/neon/lib/src/platform/platform.dart @@ -59,6 +59,11 @@ abstract interface class NeonPlatform { abstract final bool canUseSharing; + /// Whether this platform should use file dialog. + /// + /// This is needed to compensate lacking support of `https://pub.dev/packages/file_picker`. + abstract final bool shouldUseFileDialog; + FutureOr get userAccessibleAppDataPath; FutureOr init(); diff --git a/packages/neon/neon/lib/src/utils/save_file.dart b/packages/neon/neon/lib/src/utils/save_file.dart index d8cab3c8..36b27c83 100644 --- a/packages/neon/neon/lib/src/utils/save_file.dart +++ b/packages/neon/neon/lib/src/utils/save_file.dart @@ -3,9 +3,10 @@ import 'dart:typed_data'; import 'package:file_picker/file_picker.dart'; import 'package:flutter_file_dialog/flutter_file_dialog.dart'; +import 'package:neon/src/platform/platform.dart'; Future saveFileWithPickDialog(final String fileName, final Uint8List data) async { - if (Platform.isAndroid || Platform.isIOS) { + if (NeonPlatform.instance.shouldUseFileDialog) { // TODO: https://github.com/nextcloud/neon/issues/8 return FlutterFileDialog.saveFile( params: SaveFileDialogParams(