Skip to content

Commit

Permalink
Make sure saveTo returns a Future (flutter#3363)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanbeusekom authored Dec 22, 2020
1 parent 5708731 commit 7bc9aa2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
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

0 comments on commit 7bc9aa2

Please sign in to comment.