我使用一列,其中还有 2 列,并使用
MainAxisAlignment.spaceBetween
属性对齐它们,以便它们之间有一个空白空间。但在小屏幕上,我没有足够的空间容纳所有小部件,因此我决定添加 SingleChildScrollView 以允许滚动。但我遇到了一个问题,柱之间的空白空间消失了。告诉我如何添加滚动并在列之间保留空白?
代码
Expanded(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
const Divider(
color: constants.Colors.greyMiddle,
height: 1,
),
_createDrawerItem(
SvgPicture.asset(
constants.Assets.profile,
),
'My Profile'),
const Divider(
color: constants.Colors.greyMiddle,
height: 1,
),
_createDrawerItem(SvgPicture.asset(constants.Assets.profile),
'My Preferences'),
const Divider(
color: constants.Colors.greyMiddle,
height: 1,
),
_createDrawerItem(
SvgPicture.asset(constants.Assets.dashboard),
'Dashboard'),
const Divider(
color: constants.Colors.greyMiddle,
height: 1,
),
_createDrawerItem(
SvgPicture.asset(constants.Assets.wallet), 'Wallet'),
const Divider(
color: constants.Colors.greyMiddle,
height: 1,
),
],
),
// const Spacer(),
Padding(
padding: const EdgeInsets.only(bottom: 19),
child: Column(
children: [
_createDrawerItem(SvgPicture.asset(constants.Assets.invite),
'Invite & Earn !',
horPadding: 11),
_createDrawerItem(
SvgPicture.asset(constants.Assets.settings), 'Settings',
horPadding: 11),
],
),
),
],
),
),
);
添加了SingleChildScrollView
没有 SingleChildScrollView
如果你使用 SingleChildScrollView ,但是(
mainAxisAlignment: MainAxisAlignment.spaceBetwen
)无法使用。
现在你使用
SizeBox(),
使用高度不会成为响应问题
Column(
children: [
....
]
),
SizedBox(
height: 100,//custom height
),
Column(
children: [
....
]
),
或
Column(
children: [
....
]
),
Padding(
padding: EdgeInsets.only(top:100),
Column(
children: [
....
]
),
),