[英]Class 'List<_JsonQueryDocumentSnapshot>' has no instance getter 'lenght'. Receiver: Instance(length:3) of '_GrowableList' Tried calling: lenght
home page class主页 class
i am new to flutter and tying to made a ticket services application.我是 flutter 的新用户,想申请票务服务。
now i am getting this error.现在我收到这个错误。
Exception caught by widgets library小部件库捕获的异常
Class 'List<_JsonQueryDocumentSnapshot>' has no instance getter 'lenght'. Class 'List<_JsonQueryDocumentSnapshot>' 没有实例 getter 'lenght'。
Receiver: Instance(length:3) of '_GrowableList'接收器:“_GrowableList”的实例(长度:3)
Tried calling: lenght尝试调用:lenght
body: CustomScrollView(
slivers: [
SliverPersistentHeader(
pinned: true,
delegate: TextDelegateHeaderWidget(title : "My Services"),
),
//1. write Query
// model class
// ui design Widget
StreamBuilder
(
stream: FirebaseFirestore.instance.
collection("sellers").doc(sharedPreferences!.
getString("uid")).collection("brands").snapshots(),
builder: (context, AsyncSnapshot dataSnapshot)
{
if(dataSnapshot.hasData) // if brands has extis.
{
// display data
return SliverStaggeredGrid.countBuilder
(
crossAxisCount: 1,
staggeredTileBuilder: (c)=> const StaggeredTile.fit(1),
itemBuilder: (context, index)
{
Brands brandsModel = Brands.fromJson(
dataSnapshot.data!.docs[index].data() as Map<String, dynamic>);
//dataSnapshot.data!.docs[index].data()as Map<String, dynamic>);
return BrandsUiDesignWidget(
model: brandsModel,
context: context,
);
},
itemCount: dataSnapshot.data.docs.lenght,
);
}
else // if not exists.
{
return const SliverToBoxAdapter(
child: Center(
child: Text(
"No Services Exists. Please Add Some" ,
),
),
);
}
}
)
],
),
Brands class品牌 class
class _BrandsUiDesignWidgetState extends State<BrandsUiDesignWidget>
{
@override
Widget build(BuildContext context)
{
return Card(
elevation: 10,
shadowColor: Colors.black,
child: Padding(
padding: const EdgeInsets.all(0),
child: SizedBox(
height: 270,
width: MediaQuery.of(context).size.width,
child: Column(
children: [
Image.network(
widget.model!.thumbnailUrl.toString(),
height: 220,
fit: BoxFit.cover,
),
const SizedBox(height: 1,),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
widget.model!.brandTitle.toString(),
style: const TextStyle(
color: Colors.deepPurple,
fontWeight: FontWeight.bold,
fontSize: 20,
letterSpacing: 3,
),
),
IconButton(
onPressed: ()
{
} ,
icon: const Icon(
Icons.delete_sweep,
color: Colors.pinkAccent,
),
),
],
),
],
),
),
),
);
}
}
i am trying to show data in my services.我正在尝试在我的服务中显示数据。 but the code is giving this error i am new to flutter. by changing my code will be a lot helpful than explaining.但是代码给出了这个错误我是 flutter 的新手。通过更改我的代码将比解释更有帮助。 cuz I am new and don't know a lot of things.因为我是新人,很多东西都不知道。
Your code looks fine, just an error in the length
property, replace this:您的代码看起来不错,只是length
属性中的一个错误,将其替换为:
itemCount: dataSnapshot.data.docs.lenght,
with this:有了这个:
itemCount: dataSnapshot.data.docs.length,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.