2
votes

I am trying to upload an image file which I have got using imagepicker.

updatePhoto(user, File imageFile) async {
  FirebaseStorage storage = FirebaseStorage.instance;
  Reference ref = storage.ref().child('user/profile/${user.uid}');
  UploadTask uploadTask = ref.putFile(imageFile);
  String url;
  uploadTask.whenComplete(() async {
    url = await ref.getDownloadURL();
  }).catchError((onError) {
    print(onError);
  });
  return url;
}

But above code returns following error

VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method Task#startPutFile on channel plugins.flutter.io/firebase_storage) #0 MethodChannel._invokeMethod package:flutter/…/services/platform_channel.dart:156 #1 new MethodChannelTask. (package:firebase_storage_platform_interface/src/method_channel/method_channel_task.dart) flutter: MissingPluginException(No implementation found for method Reference#getDownloadURL on channel plugins.flutter.io/firebase_storage)

I would appreciate if someone could help explain how to resolve this error. Thank you

1
do flutter clean first then restart IDE then do pub get and runShubham Narkhede
Thank you so much that resolved the issue for me. I spent a considerable amount of time trying to figure out what could have gone wrong. Thanks a lot. Please post this as answer so I can accept it and other users can benefit from it.Saad Bashir

1 Answers

2
votes

First thing is that you need to do flutter clean and then fire the flutter pub get command and run your application your issue will solve.

And if still issue persists then do flutter clean then restart your IDE after that do flutter pub get and run your application.