Skip to content

Commit

Permalink
[firebase_storage] Remove StorageTaskEvent prints (firebase#1944)
Browse files Browse the repository at this point in the history
  • Loading branch information
creativecreatorormaybenot authored and collinjackson committed Aug 4, 2019
1 parent 174dfd5 commit 56c44a1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/firebase_storage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
26 changes: 26 additions & 0 deletions packages/firebase_storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<StorageTaskEvent> 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.
1 change: 0 additions & 1 deletion packages/firebase_storage/lib/src/upload_task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ abstract class StorageUploadTask {

void _changeState(StorageTaskEvent event) {
_resetState();
print('EVENT ${event.type}');
switch (event.type) {
case StorageTaskEventType.progress:
isInProgress = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_storage/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_storage
version: 3.0.4
version: 3.0.5

flutter:
plugin:
Expand Down

0 comments on commit 56c44a1

Please sign in to comment.