因此,我将数据存储在要从Firestore中获取的集合中。我正在尝试在容器下显示文档名称(该容器用于图像)。我能够获取数据并显示它。问题是,我无法正确滚动。如果我触摸图像并尝试滚动,则可以使用。但是,如果我尝试触摸列表视图并尝试滚动,则不会。
代码:
class _DescriptionPageState extends State<DescriptionPage> {
Image img;
Future<QuerySnapshot> snap;
void initState(){
super.initState();
img = Image.asset("Assets/Images/bnha.jpg");
snap = getSnap();
}
Future<QuerySnapshot> getSnap() async {
return Firestore.instance.collection('BNHA').getDocuments();
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
precacheImage(img.image, context);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
constraints: BoxConstraints.expand(height: 250),
alignment: Alignment.topLeft,
padding: const EdgeInsets.only(left: 10, top: 20),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('Assets/Images/bnha.jpg'),
fit: BoxFit.cover)),
child: GestureDetector(
child: Icon(
Icons.arrow_back,
color: Colors.white,
size: 26,
),
onTap: () => Navigator.of(context).pop()),
),
FutureBuilder(
future: snap,
builder:
(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
return Center(
child: CircularProgressIndicator(),
);
break;
default:
return ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: snapshot.data.documents.length,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title:
Text(snapshot.data.documents[index].documentID),
);
});
break;
}
})
],
),
));
}
}
我该如何解决?
答案 0 :(得分:1)
尝试在您的primary: false,
上设置ListView.builder