0

Here is the root widget . The widget has a child BuyerPostList() which is a ListView type of widget. I removing the SingleChildScrollView() gives a render exception .After adding it the error no longer appears but the page is still not scrollable.

class PostsPage extends StatelessWidget {
  final AuthService _auth = AuthService();
  @override
  Widget build(BuildContext context) {
    return StreamProvider<List<BuyerPost>>.value(
        value: BuyerDatabaseService().buyerPosts,
    child:Scaffold(
      backgroundColor: Colors.white,
      appBar: header(context,isAppTitle: true),
        body:Container(
            child: SingleChildScrollView(
              child: Column(
                children: <Widget>[
                  BuyerPostList(),
                  SizedBox(height: 100,),
                ],
              ),
            ),
        ),
      floatingActionButton: FloatingActionButton.extended(
        onPressed: () {
          Navigator.push(
            context,
            MaterialPageRoute(builder: (context) => NewPost()),
          );
        },
        label: Text(
          'New',
          style: TextStyle(fontWeight:FontWeight.w900,color:Color.fromRGBO(0, 0, 0, 0.4),),
        ),
        icon: Icon(Icons.add,color:Color.fromRGBO(0, 0, 0, 0.4),),
        backgroundColor:Colors.white,
      ),
    ),
    );
  }
}


Here is the List View BuyerPostList widget()

class BuyerPostList extends StatefulWidget {
  @override
  _BuyerPostListState createState() => _BuyerPostListState();
}

class _BuyerPostListState extends State<BuyerPostList> {
  @override
  Widget build(BuildContext context) {

    final posts = Provider.of<List<BuyerPost>>(context) ?? [];
    return ListView.builder(
      shrinkWrap: true,
      itemCount: posts.length,
      itemBuilder: (context, index) {
        return BuyerPostTile(post: posts[index]);
      },
    );
  }
}

I hope i've been clear enough by my explanation. How will i make it scrollable?. Thanks in advance.

Bright
  • 707
  • 2
  • 10
  • 22

1 Answers1

1

Add physics: NeverScrollableScrollPhysics(), inside ListView.builder(

Code:

@override
  Widget build(BuildContext context) {

    final posts = Provider.of<List<BuyerPost>>(context) ?? [];
    return ListView.builder(
      shrinkWrap: true,
      physics: NeverScrollableScrollPhysics(),
      itemCount: posts.length,
      itemBuilder: (context, index) {
        return BuyerPostTile(post: posts[index]);
      },
    );
  }
Jitesh Mohite
  • 31,138
  • 12
  • 157
  • 147