【问题标题】:Undefined name 'storage'. Try correcting the name to one that is defined, or defining the name未定义的名称“存储”。尝试将名称更正为已定义的名称,或定义名称
【发布时间】:2022-06-10 20:50:56
【问题描述】:

我正在制定一种从 Firebase 存储中检索图像的方法,请告诉我如何解决此错误

Future<List<Map<String, dynamic>>> _loadImage() async {
        List<Map<String, dynamic>> files = [];
    
        final ListResult result = await storage.ref('pizza').list();//Undefined name 'storage'.
    Try correcting the name to one that is defined, or defining the name.
        final List<Reference> allFiles = result.items;
    
        await Future.forEach<Reference>(allFiles, (file) async {
          final String fileUrl = await file.getDownloadURL();
          final FullMetadata fileMeta = await file.getMetadata();
          files.add({
            "url": fileUrl,
          });
        });
    
        return files;
      }

【问题讨论】:

    标签: flutter firebase dart dart-null-safety


    【解决方案1】:

    您缺少storage 变量的定义。您是否只是从某个地方将其复制粘贴到您的代码中?尝试改用FirebaseFirestore.instance。

    【讨论】:

      猜你喜欢
      • 2020-09-03
      • 2023-02-07
      • 2022-08-22
      • 1970-01-01
      • 2021-11-28
      • 2020-01-28
      • 2020-11-01
      • 2021-03-24
      • 1970-01-01
      相关资源
      最近更新 更多