build: Use file selector to save files
This commit is contained in:
parent
ef85d48a47
commit
8f483c64c0
2 changed files with 10 additions and 17 deletions
|
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:file_selector/file_selector.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
|
@ -19,21 +20,18 @@ extension MatrixFileExtension on MatrixFile {
|
|||
return;
|
||||
}
|
||||
|
||||
final downloadPath = await FilePicker.platform.saveFile(
|
||||
dialogTitle: L10n.of(context).saveFile,
|
||||
fileName: name,
|
||||
type: filePickerFileType,
|
||||
bytes: bytes,
|
||||
final location = await getSaveLocation(
|
||||
suggestedName: name,
|
||||
confirmButtonText: L10n.of(context).saveFile,
|
||||
);
|
||||
final downloadPath = location?.path;
|
||||
if (downloadPath == null) return;
|
||||
|
||||
if (PlatformInfos.isDesktop) {
|
||||
final result = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => File(downloadPath).writeAsBytes(bytes),
|
||||
);
|
||||
if (result.error != null) return;
|
||||
}
|
||||
final result = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => File(downloadPath).writeAsBytes(bytes),
|
||||
);
|
||||
if (result.error != null) return;
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
|
|
|
|||
|
|
@ -61,11 +61,6 @@ parts:
|
|||
build-packages:
|
||||
- g++
|
||||
|
||||
zenity-integration:
|
||||
plugin: nil
|
||||
stage-snaps:
|
||||
- zenity-integration
|
||||
|
||||
fluffychat:
|
||||
plugin: flutter
|
||||
source: .
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue