2

Flutter is complaining that a getter is missing on firebase_storage::StorageUploadTask, but when I open the declaration, it's there.

/flutter ( 3107): [ERROR:flutter/shell/common/shell.cc(182)] Dart 
Error: Unhandled exception:
E/flutter ( 3107): 'package:flutter_project/widgets/screen.dart': error: line 284 pos 43: lib/widgets/camera_screen.dart:284:43: Error: The getter 'future' isn't defined for the class 'firebase_storage::StorageUploadTask'.
E/flutter ( 3107): Try correcting the name to the name of an existing getter, or defining a getter or field named 'future'.
E/flutter ( 3107):     final downloadUrl = (await uploadTask.future).downloadUrl;
E/flutter ( 3107):                                           ^

Firebase Storage code (You can see that "get future" is the last item in the class.):

abstract class StorageUploadTask {
  final FirebaseStorage _firebaseStorage;
  final String _path;
  final StorageMetadata _metadata;

  StorageUploadTask._(this._firebaseStorage, this._path, this._metadata);
  Future<void> _start();

  Completer<UploadTaskSnapshot> _completer =
      new Completer<UploadTaskSnapshot>();
  Future<UploadTaskSnapshot> get future => _completer.future;
}

Flutter Doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v0.10.1-pre.39, on Mac OS X 10.14 18A391, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
[✓] Android Studio (version 3.1)
[!] IntelliJ IDEA Community Edition (version 2017.1.5)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.27.2)
[✓] Connected device (1 available)

! Doctor found issues in 1 category.

Dependency from pubspec.yaml:

firebase_storage: ^1.0.4

I just updated Flutter. Before updating I didn't have this problem, only after updating.

Also, sometimes I get the error during compile, but other times only after the app is running on a device.

This just doesn't make sense.

Edit

Apparently, the code that I saw when I used the "Go to definition" tool in VS Code wasn't the right code. I tried doing several things that were suggested (revert to firebase_storage version 1.0.2, use .onComplete instead of .future), and none of these things worked. So I decided to give up for the night.

This morning, the code in firebase_storage is different. I'm not sure if VS Code has a caching issue or not, but that seems like the problem. Now I see that .future isn't there, but that I could use .onComplete. I changed the code to use .onComplete, which worked.

Maybe I wouldn't have had this problem if I was using IntelliJ or Android Studio.

klavergne
  • 143
  • 1
  • 1
  • 10

1 Answers1

1

Based on the suggestions by @anmol.majhail, I was able to get it working. I reverted back to version 1.0.2 of firebase_storage and changed from using .future to .onComplete.

It didn't work until several hours after originally trying, so there seems to be an issue where VS Code is caching dependencies, but I'm not sure why or for how long.

klavergne
  • 143
  • 1
  • 1
  • 10