【问题标题】:The argument type 'Set<String>' can't be assigned to the parameter type 'Map<String, dynamic>'参数类型“Set<String>”不能分配给参数类型“Map<String, dynamic>”
【发布时间】:2021-05-17 04:38:13
【问题描述】:

我的 PRODUCT.DART 页面

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:uuid/uuid.dart';

class ProductService{
  FirebaseFirestore _firestore = FirebaseFirestore.instance;
  String ref = "products";

  void uploadProduct({String productName, String brand, String category, int quantity, List sizes, List images, double price}){
    var id = Uuid();
    String productId = id.v1();

_firestore.collection(ref).doc(productId).set({
  "name" = productName,
  "brand" = brand,
  "id" = productId,
  "category" = category,
});


 }
}

我的问题是:我无法将这些变量包含在 data() 方法中

错误:

error: The argument type 'Set<String>' can't be assigned to the parameter type 'Map<String, dynamic>'. (argument_type_not_assignable at [ecommerceadmin_app] lib\db\product.dart:12)

【问题讨论】:

    标签: firebase flutter dart


    【解决方案1】:

    将 = 替换为 : 如下:

    _firestore.collection(ref).doc(productId).set({
      "name": productName,
      "brand": brand,
      "id": productId,
      "category": category,
    });
    

    【讨论】:

      猜你喜欢
      • 2020-12-15
      • 2021-09-06
      • 2021-08-29
      • 2021-10-02
      • 2021-03-23
      • 1970-01-01
      • 2023-04-05
      • 2020-12-27
      相关资源
      最近更新 更多