为什么我的 Flutter 代码中的行之间有这么多空间?

问题描述

Positioned(
          bottom: 15,left: 15,child: SizedBox(
            height: 100,child: Column(
              children: [
                Row(
                  children: [
                    ElevatedButton(
                      style: TextButton.styleFrom(
                        padding: EdgeInsets.zero,minimumSize: Size(40,20),backgroundColor: colorSet.buttonForeground,),onpressed: () {},child: Text(
                        'Once',style: TextStyle(
                          color: colorSet.text,fontSize: 12,SizedBox(
                      width: 8,ElevatedButton(
                      style: TextButton.styleFrom(
                        padding: EdgeInsets.zero,child: Text(
                        'Specific Days',],Row(
                  children: [
                    ElevatedButton(
                      style: TextButton.styleFrom(
                        padding: EdgeInsets.zero,child: Text(
                        'Daily',SizedBox(
                      width: 3,child: Text(
                        'Weekly',))

嗨,我对 Flutter 比较陌生。我正在尝试为家务制作一张卡片,而卡片的这一特定部分给我带来了问题。 我不知道,为什么每行之间有这么多垂直空间(每行基本上有两个按钮)。我已经尝试了几件事来解决这个问题,但我现在放弃并来这里寻求建议。 谢谢!

Layout View.

解决方法

试试这个,去掉 Sizedbox(height:100)

另外,您可以删除行内的 SizedBox(width : 8) 并尝试 Row(mainAxisAlignment:MainAxisAlignment.spaceBetween,children:[]);

Positioned(
          bottom: 15,left: 15,child:  Column(
              children: [
                Row(
                 mainAxisAlignment:MainAxisAlignment.spaceBetween,children: [
                    ElevatedButton(
                      style: TextButton.styleFrom(
                        padding: EdgeInsets.zero,minimumSize: Size(40,20),backgroundColor: colorSet.buttonForeground,),onPressed: () {},child: Text(
                        'Once',style: TextStyle(
                          color: colorSet.text,fontSize: 12,ElevatedButton(
                      style: TextButton.styleFrom(
                        padding: EdgeInsets.zero,child: Text(
                        'Specific Days',],Row(
                    mainAxisAlignment:MainAxisAlignment.spaceBetween,child: Text(
                        'Daily',child: Text(
                        'Weekly',)) 

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...