Listview scrollable in container code example

Example 1: make recycler view non scrollable

//Override your LayoutManager's canScrollVertically::boolean
linearLayoutManager = new LinearLayoutManager(context) {
 
 public boolean canScrollVertically() {
  return false;
 }
};

Example 2: scroll column with listview

SingleChildScrollView(
        physics: ScrollPhysics(),
        child: Column(
          children: <Widget>[
             Text('Hey'),
             ListView.builder(
                physics: NeverScrollableScrollPhysics(),
                shrinkWrap: true,
                itemCount:18,
                itemBuilder: (context,index){
                  return  Text('Some text');
                })
          ],
        ),
      ),

Example 3: make scaffold scrollable flutter


 Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text('News'),
    ),
    body: SingleChildScrollView(  // <-- wrap this around
      child: Column(
        children: <Widget>[
        ],
      ),
    ));
  }

Tags:

Dart Example