[英]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!我需要列内的列表视图(它是 SingleChildScrollView 的子项),但它没有显示出来!
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'),
],
)
],
),
),
);
}
}
SingleChildScrollView
should be removed and ListView
should be wrapped with Expanded
widget SingleChildScrollView
应该被删除并且ListView
应该用Expanded
小部件包裹
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.由于 ListView 的高度是无限的,而 Column 小部件想要子项的高度值。 It gives an hasSize expection它给出了 hasSize 期望
Adding shrinkWrap: true inside ListView should resolve the error在 ListView 中添加shrinkWrap: true应该可以解决错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.