diff --git a/packages/firebase_storage/CHANGELOG.md b/packages/firebase_storage/CHANGELOG.md index d9fbd1d1fe6c..86b8003b2fea 100644 --- a/packages/firebase_storage/CHANGELOG.md +++ b/packages/firebase_storage/CHANGELOG.md @@ -1,3 +1,9 @@ +## 3.0.5 +* Removed automatic print statements for `StorageTaskEvent`'s. + If you want to see the event status in your logs now, you will have to use the following: + `storageReference.put{File/Data}(..).events.listen((event) => print('EVENT ${event.type}'));` +* Updated `README.md` to explain the above. + ## 3.0.4 * Update google-services Android gradle plugin to 4.3.0 in documentation and examples. diff --git a/packages/firebase_storage/README.md b/packages/firebase_storage/README.md index 370f50abda11..70aea955cd52 100755 --- a/packages/firebase_storage/README.md +++ b/packages/firebase_storage/README.md @@ -9,8 +9,34 @@ For Flutter plugins for other Firebase products, see [FlutterFire.md](https://gi *Note*: This plugin is still under development, and some APIs might not be available yet. [Feedback](https://github.com/flutter/flutter/issues) and [Pull Requests](https://github.com/flutter/plugins/pulls) are most welcome! ## Usage + To use this plugin, add `firebase_storage` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). +### Logging + +If you wish to see status events for your upload tasks in your logs, you should listen to the `StorageUploadTask.events` stream. +This could look like the following if you are using `StorageReference.putData`: + +```dart +final StorageReference storageReference = FirebaseStorage().ref().child(path); + +final StorageUploadTask uploadTask = storageReference.putData(data); + +final StreamSubscription streamSubscription = uploadTask.events.listen((event) { + // You can use this to notify yourself or your user in any kind of way. + // For example: you could use the uploadTask.events stream in a StreamBuilder instead + // to show your user what the current status is. In that case, you would not need to cancel any + // subscription as StreamBuilder handles this automatically. + + // Here, every StorageTaskEvent concerning the upload is printed to the logs. + print('EVENT ${event.type}'); +}); + +// Cancel your subscription when done. +await uploadTask.onComplete; +streamSubscription.cancel(); +``` + ## Getting Started See the `example` directory for a complete sample app using Firebase Cloud Storage. diff --git a/packages/firebase_storage/lib/src/upload_task.dart b/packages/firebase_storage/lib/src/upload_task.dart index 9c263779e7e1..70d4f9ebcc61 100644 --- a/packages/firebase_storage/lib/src/upload_task.dart +++ b/packages/firebase_storage/lib/src/upload_task.dart @@ -56,7 +56,6 @@ abstract class StorageUploadTask { void _changeState(StorageTaskEvent event) { _resetState(); - print('EVENT ${event.type}'); switch (event.type) { case StorageTaskEventType.progress: isInProgress = true; diff --git a/packages/firebase_storage/pubspec.yaml b/packages/firebase_storage/pubspec.yaml index c479081607f1..cffac66c8a1b 100755 --- a/packages/firebase_storage/pubspec.yaml +++ b/packages/firebase_storage/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for Firebase Cloud Storage, a powerful, simple, and cost-effective object storage service for Android and iOS. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_storage -version: 3.0.4 +version: 3.0.5 flutter: plugin: