【发布时间】:2022-01-05 16:02:48
【问题描述】:
你好... 至少在我的两个页面上,我几乎遇到了这个问题,我做了很多来解决它,但似乎我做不到。 这是我在产品页面中的代码:
import 'package:cloud_firestore/cloud_firestore.dart';
class ProductModel {
static const ID = "id";
static const NAME = "name";
static const PICTURE = "picture";
static const PRICE = "price";
static const DESCRIPTION = "description";
String _id;
String _name;
String _picture;
String _description;
String get id => _id;
String get name => _name;
String get picture => _picture;
String get brand => _brand;
String get category => _category;
String get description => _description;
ProductModel.fromSnapshot(DocumentSnapshot snapshot) {
_id = snapshot.data[ID];
_brand = snapshot.data[BRAND];
_sale = snapshot.data[SALE];
_description = snapshot.data[DESCRIPTION] ?? " ";
}
}
这里给出了错误
The operator '[]' isn't defined for the type 'Object Function()'.
指的是模型...
这里是 pubspec.yaml
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
carousel_pro: any
google_sign_in: ^5.2.1
firebase_storage: ^10.1.0
cloud_firestore: ^3.1.0
firebase_core: ^1.10.0
firebase_auth: ^3.2.0
firebase_analytics: ^8.3.4
shared_preferences: ^2.0.9
image_picker: ^0.8.4+4
firebase_database: ^8.1.0
flutter_search_panel: any
intl: ^0.17.0
provider: ^6.0.1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.4
carousel_slider: ^4.0.0
transparent_image: ^2.0.0
flutter_spinkit: ^5.1.0
uuid: ^3.0.5
flutter_typeahead: ^3.2.3
如果有任何帮助,我将不胜感激
非常感谢
【问题讨论】:
标签: android flutter flutter-dependencies