Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot put ListView inside Column in flutter?

I need listview inside the Column(which is the child of SingleChildScrollView), but it is not showing up!

import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

class BalanceScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Column(
          children: [
            Padding(padding: const EdgeInsets.symmetric(vertical: 24), child: Center(child: Text('15 960 UZS',),),),
            Container(height: 48, alignment: Alignment.centerLeft, padding: EdgeInsets.symmetric(horizontal: 24), 
              child: Row(children: [Text('Refill balance',), Spacer(), FaIcon(FontAwesomeIcons.chevronRight, size: 15,),],),),
            
            ///this is causing problem! But i need listview here
            ListView(
              children: [
                Text('some text 1'),
                Text('some text 2'),
              ],
            )
          ],
        ),
      ),
    );
  }
}

this is showing up in terminal: enter image description here

like image 698
Akbar Pulatov Avatar asked Jul 11 '26 10:07

Akbar Pulatov


1 Answers

SingleChildScrollView should be removed and ListView should be wrapped with Expanded widget

 Expanded(   
      child:ListView(
              children: [
                Text('some text 1'),
                Text('some text 2'),
              ],
            )
       )

Since the ListView height is infinite and Column widget wants to height value of children. It gives an hasSize expection

like image 67
Furkan Avatar answered Jul 13 '26 23:07

Furkan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!