how to use flexible in listview in flutterr?

Viewed 50

I'm trying to make backgroundcolor different from Flexible area to the end of the Listview , but I guess it's in the listview so can't apply.. how can I make backgroundcolor different after the Text(my Identification)?

body:
  ListView(
    scrollDirection: Axis.vertical,
    physics: ClampingScrollPhysics(),  
    shrinkWrap: true,
    children: [
  Column(
    children: [
      Container(
        
  
      ),
      Container(
        
          
      ),
      Container(
        
      ),
      Container(
          
      ),
      Container(
        width: double.infinity,
        height: 100,
        child: Row(
          children:[
            Text("My Identification"),
        ]
      )

      ),
      Flexible(
        fit: FlexFit.loose,
        child: Container(
          child: SingleChildScrollView(
            padding: EdgeInsets.only(top: 100),
            scrollDirection: Axis.horizontal,
            child: Row(
              children: [
                cardWidget("card1", "drivelisence"),
                cardWidget("card2", "IdCard"),
                cardWidget("card3",   "deploma")
              ],
            ),
          ),
        )),
    ],
    
  )
    
      ]
  )
1 Answers

actually I am afraid you can't using your widgets the ListView has unbounded height so you can not use flexible widgets because it will expand to infinity Way to use Expanded inside ListView or SingleChildScrollView,wrap the widget with CustomScrollView and you’re able to use expanded inside scrollable widgets.

CustomScrollview( 
  slivers: [
  SliverFillRemaining(
   hasscrollBody: false,
    child: Column(
      children: [
       Container(
      
       ),
     Container(
      width: double.infinity,
      height: 100,
      child: Row(
       children:[
        Text("My Identification"),
       ]
     )
   ),
   Flexible(
    fit: FlexFit.loose,
    child: Container(
      child: SingleChildScrollView(
        padding: EdgeInsets.only(top: 100),
        scrollDirection: Axis.horizontal,
        child: Row(
          children: [
            cardWidget("card1", "drivelisence"),
            cardWidget("card2", "IdCard"),
            cardWidget("card3",   "deploma")
          ],
        ),
      ),
    )),
    ]
   ), // Column
Related