我的产品.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)
答案 0 :(得分:0)
将 = 替换为 : 如下:
_firestore.collection(ref).doc(productId).set({
"name": productName,
"brand": brand,
"id": productId,
"category": category,
});