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:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:file_picker/file_picker.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:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
@ -19,21 +20,18 @@ extension MatrixFileExtension on MatrixFile {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final downloadPath = await FilePicker.platform.saveFile(
|
final location = await getSaveLocation(
|
||||||
dialogTitle: L10n.of(context).saveFile,
|
suggestedName: name,
|
||||||
fileName: name,
|
confirmButtonText: L10n.of(context).saveFile,
|
||||||
type: filePickerFileType,
|
|
||||||
bytes: bytes,
|
|
||||||
);
|
);
|
||||||
|
final downloadPath = location?.path;
|
||||||
if (downloadPath == null) return;
|
if (downloadPath == null) return;
|
||||||
|
|
||||||
if (PlatformInfos.isDesktop) {
|
final result = await showFutureLoadingDialog(
|
||||||
final result = await showFutureLoadingDialog(
|
context: context,
|
||||||
context: context,
|
future: () => File(downloadPath).writeAsBytes(bytes),
|
||||||
future: () => File(downloadPath).writeAsBytes(bytes),
|
);
|
||||||
);
|
if (result.error != null) return;
|
||||||
if (result.error != null) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,6 @@ parts:
|
||||||
build-packages:
|
build-packages:
|
||||||
- g++
|
- g++
|
||||||
|
|
||||||
zenity-integration:
|
|
||||||
plugin: nil
|
|
||||||
stage-snaps:
|
|
||||||
- zenity-integration
|
|
||||||
|
|
||||||
fluffychat:
|
fluffychat:
|
||||||
plugin: flutter
|
plugin: flutter
|
||||||
source: .
|
source: .
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue