I want to build a instagram-like profile page, where all the posts of the current user are listed in a feed. Above that, some information about the user (avatar, follower count, post count, bio, etc.) should be displayed. The user should be able to scroll the whole page. At the moment the page can only be scrolled to the height of the sizedBox-widget in my ListView.builder. Just like that:
The build method of ProfilePage class looks like that:
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(),
body: ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 25.0, top: 30.0),
child: Text(_user.displayName,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 20.0)),
),
...(all the other information for the "header-part")
postImagesWidget(),
])));}
In postImagesWidget I'm using a ListView.builder to build the feed:
Widget postImagesWidget(){
return FutureBuilder(
future: _future,
builder:
((context, AsyncSnapshot<List<DocumentSnapshot>> snapshot) {
if (snapshot.hasData) {
if (snapshot.connectionState == ConnectionState.done) {
return SizedBox(
height: 600,
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
//shrinkWrap: true,
itemCount: snapshot.data.length,
itemBuilder: ((context, index) => ListItem(
list: snapshot.data,
index: index,
user: _user))));
} else {
return Center(
child: CircularProgressIndicator(),
);
}
} else {
return Center(
child: CircularProgressIndicator(),
);
}
}),
);
}
I had to add a sizedBox-Widget to avoid this error:
Another exception was thrown: RenderBox was not laid out: RenderViewport#50ccf NEEDS-PAINT
The description of this error says that I should add shrinkwrap to my ListView.builder, but this crashes my whole app after some scrolling with this error:
Failed assertion: line 470 pos 12: 'child.hasSize': is not true.
How can I make the whole page scrollable and not the two parts (header & feed) separately?
I know that i has something to do with the fact, that I am using a ListView.builder inside a ListView...
Best Regards.