Flutter Load Image from Firebase Storage

前端 未结 3 573
盖世英雄少女心
盖世英雄少女心 2020-12-05 18:29

I see there are a lot of examples on how to upload an image using flutter to firebase storage but nothing on actually downloading/reading/displaying one that\'s already bee

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 19:27

    update

    In newer versions use

    await ref.getDownloadURL();
    

    See How to get full downloadUrl from UploadTaskSnapshot in Flutter?

    original

    someMethod() async {
      var data = await FirebaseStorage.instance.ref().child("foo$rand.txt").getData();
      var text = new String.fromCharCodes(data);
      print(data);
    }
    

    see Download an image from Firebase to Flutter

    or

    final uploadTask = imageStore.putFile(imageFile);
    final url = (await uploadTask.future).downloadUrl;
    

    In the later case you'd need to store the downloadUrl somewhere and then use NetworkImage or similar to get it rendered.

提交回复
热议问题