Reputation: 101
I have a widget ListView but still I can't scroll through the pictures. I tried replacing Column but still it didn't work for me. Is there any other option?
Also, when I wrap StreamBuilder with SingleChildScrollView I get following error:
RenderBox was not laid out: RenderRepaintBoundary#9fda5 relayoutBoundary=up11 NEEDS-PAINT 'package:flutter/src/rendering/box.dart': Failed assertion: line 1702 pos 12: 'hasSize'
Here is my code:
StreamBuilder(
stream: Firestore.instance
.collection('userImage')
// .orderBy('date', descending: true)
.where('name', isEqualTo: name)
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return Center(child: CircularProgressIndicator());
return ListView(
children: [
Row(
children: [
Text('$name'),
IconButton(
icon: Icon(
Icons.open_in_new,
size: 30,
color: Colors.grey,
),
onPressed: logout)
],
),
Row(
children: [
Image.asset(
'assets/like.png',
height: 30,
width: 30,
),
Image.asset(
'assets/donate.png',
height: 30,
width: 30,
),
Icon(
Icons.offline_bolt,
color: Colors.grey,
size: 36,
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 100, right: 100, top: 50, bottom: 50),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15)),
child: SizedBox(
height: 50,
child: Center(
child: Text(
'order pics & clips',
style: TextStyle(color: Colors.white),
)),
),
onPressed: () {
print(name);
print(email);
print(account);
},
),
),
ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: snapshot.data.documents.length,
itemBuilder: (context, i) {
return Column(
children: [
ProfilePost(
snapshot.data.documents[i]['url'],
snapshot.data.documents[i]['likes'].toString(),
snapshot.data.documents[i]['donations']
.toString())
],
);
}),
],
);
}),
Upvotes: 0
Views: 42
Reputation: 1232
You could use the shrinkWrap: true
property on the ListView()
and ListView.builder()
widgets so that the total size (height) of the listview is the sum of the heights of the children.
Upvotes: 0