无法将 ListView 放入 Column 中?
Cannot put ListView inside Column in flutter?
我需要 Column 中的列表视图(它是 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
应该被删除,ListView
应该用 Expanded
widget
包装起来
Expanded(
child:ListView(
children: [
Text('some text 1'),
Text('some text 2'),
],
)
)
由于 ListView 的高度是无限的,而 Column 小部件想要子项的高度值。它给出了 hasSize 期望
在 ListView 中添加 shrinkWrap: true 应该可以解决错误
我需要 Column 中的列表视图(它是 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
应该被删除,ListView
应该用 Expanded
widget
Expanded(
child:ListView(
children: [
Text('some text 1'),
Text('some text 2'),
],
)
)
由于 ListView 的高度是无限的,而 Column 小部件想要子项的高度值。它给出了 hasSize 期望
在 ListView 中添加 shrinkWrap: true 应该可以解决错误