flutter / dart error: The argument type 'Future' can't be assigned to the parameter type 'File'

前端 未结 4 1696
时光说笑
时光说笑 2021-02-14 06:12

I\'m trying to build my first mobile application with flutter and firebase. When I try to display and store a photo I have the following issue :

error: T

4条回答
  •  我在风中等你
    2021-02-14 07:09

    ref.put asks for a File as parameter. What you are passing is a Future.

    You need to wait for the result of that future to make your call.

    You can change your code to

    final StorageUploadTask uploadTask = ref.put(await _imageFile);
    final Uri downloadUrl = (await uploadTask.future).downloadUrl;
    

    Or change _imageFile to File instead of Future

提交回复
热议问题