1
1
import 'dart:io' ;
2
2
3
+ import 'package:file_selector/file_selector.dart' ;
3
4
import 'package:flutter/material.dart' ;
4
5
5
6
import 'package:file_picker/file_picker.dart' ;
6
- import 'package:file_selector/file_selector.dart' ;
7
7
import 'package:flutter_gen/gen_l10n/l10n.dart' ;
8
8
import 'package:matrix/matrix.dart' ;
9
9
import 'package:share_plus/share_plus.dart' ;
@@ -20,18 +20,27 @@ extension MatrixFileExtension on MatrixFile {
20
20
return ;
21
21
}
22
22
23
- final location = await getSaveLocation (
24
- suggestedName: name,
25
- confirmButtonText: L10n .of (context).saveFile,
26
- );
27
- final downloadPath = location? .path;
23
+ final downloadPath = ! PlatformInfos .isMobile
24
+ ? (await getSaveLocation (
25
+ suggestedName: name,
26
+ confirmButtonText: L10n .of (context).saveFile,
27
+ ))
28
+ ? .path
29
+ : await FilePicker .platform.saveFile (
30
+ dialogTitle: L10n .of (context).saveFile,
31
+ fileName: name,
32
+ type: filePickerFileType,
33
+ bytes: bytes,
34
+ );
28
35
if (downloadPath == null ) return ;
29
36
30
- final result = await showFutureLoadingDialog (
31
- context: context,
32
- future: () => File (downloadPath).writeAsBytes (bytes),
33
- );
34
- if (result.error != null ) return ;
37
+ if (PlatformInfos .isDesktop) {
38
+ final result = await showFutureLoadingDialog (
39
+ context: context,
40
+ future: () => File (downloadPath).writeAsBytes (bytes),
41
+ );
42
+ if (result.error != null ) return ;
43
+ }
35
44
36
45
ScaffoldMessenger .of (context).showSnackBar (
37
46
SnackBar (
0 commit comments