Make sure saveTo returns a Future (#3363)
diff --git a/packages/cross_file/CHANGELOG.md b/packages/cross_file/CHANGELOG.md
index 1716cb5..5ad9197 100644
--- a/packages/cross_file/CHANGELOG.md
+++ b/packages/cross_file/CHANGELOG.md
@@ -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))
diff --git a/packages/cross_file/lib/src/types/base.dart b/packages/cross_file/lib/src/types/base.dart
index 6dc2d51..1a1b569 100644
--- a/packages/cross_file/lib/src/types/base.dart
+++ b/packages/cross_file/lib/src/types/base.dart
@@ -18,7 +18,7 @@
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.');
}
diff --git a/packages/cross_file/lib/src/types/html.dart b/packages/cross_file/lib/src/types/html.dart
index 269f2a8..6469396 100644
--- a/packages/cross_file/lib/src/types/html.dart
+++ b/packages/cross_file/lib/src/types/html.dart
@@ -108,7 +108,7 @@
/// 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');
diff --git a/packages/cross_file/lib/src/types/io.dart b/packages/cross_file/lib/src/types/io.dart
index 81b8cdd..d9a9355 100644
--- a/packages/cross_file/lib/src/types/io.dart
+++ b/packages/cross_file/lib/src/types/io.dart
@@ -57,7 +57,7 @@
}
@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();
diff --git a/packages/cross_file/pubspec.yaml b/packages/cross_file/pubspec.yaml
index 0c7f306..4c9acf9 100644
--- a/packages/cross_file/pubspec.yaml
+++ b/packages/cross_file/pubspec.yaml
@@ -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: