无法使用column()颤动将我的小部件置于容器中
在这张照片上是我的 step1
,当我使用column()时,我的设计不是中心:(观看它- &gt
;请参阅任何错误:
Expanded(
child: Padding(
padding: const EdgeInsets.all(10),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: colorMars,
),
height: 200,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
icon: const FaIcon(
FontAwesomeIcons.mars,
size: 80,
),
onPressed: () {
colorMars = active;
if (colorMars == active) {
colorVenus = inActive;
} else {
colorMars = inActive;
}
setState(() {});
}),
],
),
),
),
),
图标的ps我使用此软件包 font_awsome_flutter 在pubspec.yaml中:
dependencies:
flutter:
sdk: flutter
font_awesome_flutter: ^10.1.0
这里有完整的代码 - > full_code
On this pic is my
step1
And when I use Column(), my design isn't a center :( Watch it -> step2
also I cant press on it when I wrapped in Column() and I dont see any mistakes:
Expanded(
child: Padding(
padding: const EdgeInsets.all(10),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: colorMars,
),
height: 200,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
icon: const FaIcon(
FontAwesomeIcons.mars,
size: 80,
),
onPressed: () {
colorMars = active;
if (colorMars == active) {
colorVenus = inActive;
} else {
colorMars = inActive;
}
setState(() {});
}),
],
),
),
),
),
PS For icons I use this package font_awesome_flutter
In pubspec.yaml:
dependencies:
flutter:
sdk: flutter
font_awesome_flutter: ^10.1.0
Full of code here -> full_code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加
IconSize:80
在您的iconbutton
中。完整的代码将基于
iconbutton
如果您覆盖
faicon
带有80的尺寸,而无需添加iconbutton
大小,则faicon
将大于其父(iconbutton
) )您会得到意外的布局。Add
iconSize: 80
in yourIconButton
. And full code will beBased on the
IconButton
documentationIf you override
FaIcon
with size 80 without addingIconButton
size, theFaIcon
will be bigger than its parent (IconButton
) and you get unexpected layout.