Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[cross_file] Make sure saveTo returns a Future #3363

Merged
merged 1 commit into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/cross_file/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.0

* **breaking change** Make sure the `saveTo` method returns a `Future` so it can be awaited and users are sure the file has been written to disk.

## 0.1.0+2

* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276))
Expand Down
2 changes: 1 addition & 1 deletion packages/cross_file/lib/src/types/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class XFileBase {
XFileBase(String path);

/// Save the CrossFile at the indicated file path.
void saveTo(String path) async {
Future<void> saveTo(String path) {
throw UnimplementedError('saveTo has not been implemented.');
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cross_file/lib/src/types/html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class XFile extends XFileBase {

/// Saves the data of this CrossFile at the location indicated by path.
/// For the web implementation, the path variable is ignored.
void saveTo(String path) async {
Future<void> saveTo(String path) async {
// Create a DOM container where we can host the anchor.
_target = ensureInitialized('__x_file_dom_element');

Expand Down
2 changes: 1 addition & 1 deletion packages/cross_file/lib/src/types/io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class XFile extends XFileBase {
}

@override
void saveTo(String path) async {
Future<void> saveTo(String path) async {
File fileToSave = File(path);
await fileToSave.writeAsBytes(_bytes ?? (await readAsBytes()));
await fileToSave.create();
Expand Down
2 changes: 1 addition & 1 deletion packages/cross_file/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: cross_file
description: An abstraction to allow working with files across multiple platforms.
homepage: https://github.com/flutter/plugins/tree/master/packages/cross_file
version: 0.1.0+2
version: 0.2.0

dependencies:
flutter:
Expand Down