主页类
我是新来的,扑和搭售,提出了票务服务的申请。
现在我得到这个错误。
微件库捕获到异常
类别'List<_JsonQueryDocumentSnapshot>'没有执行严修getter '长度'。
接收方:'_GrowableList'的示例(长度:3)
已尝试呼叫:长度
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" ,
),
),
);
}
}
)
],
),
品牌类别
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,
),
),
],
),
],
),
),
),
);
}
}
我试图在我的服务中显示数据。但代码是给这个错误,我是新的Flutter。通过改变我的代码将是一个很大的帮助比解释。因为我是新的,不知道很多事情。
1条答案
按热度按时间vbkedwbf1#
您的代码看起来很好,只是
length
属性中有错误,请替换为:与此: