我想将(+,-)图标和TextField
对准相同的Vertical
位置。但是我不明白这一点。这是我的代码。
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
InkWell(
child: Icon(Icons.remove ,color: Colors.white),
onTap: (){},
),
Container(
width: 35,
height: 40,
child: TextField(
inputFormatters:[WhitelistingTextInputFormatter(RegExp(digit_Reg_Expression))],
keyboardType: TextInputType.number,
textAlign: TextAlign.center,
cursorColor: Colors.green,
controller: Controler_size[index],
),
),
InkWell(
child: Icon(Icons.add,color: Colors.white),
onTap: (){},
)
],
)
请帮助我将这些Widgets
垂直放置,以便它们在相同的垂直位置对齐。enter image description here
如果要放置元素vertically
,请使用Column
小部件。如果要放置元素horizontally
,请使用Row
小部件。
检查下面的代码:效果很好:
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
InkWell(
child: Icon(Icons.remove ,color: Colors.white),
onTap: (){},
),
Container(
width: 35,
height: 40,
child: TextField(
inputFormatters:[WhitelistingTextInputFormatter(RegExp(digit_Reg_Expression))],
keyboardType: TextInputType.number,
textAlign: TextAlign.center,
cursorColor: Colors.green,
controller: Controler_size[index],
),
),
InkWell(
child: Icon(Icons.add,color: Colors.white),
onTap: (){},
)
],
)
我希望这会有所帮助。