【发布时间】:2021-05-22 02:53:51
【问题描述】:
我有一个创建文本字段的函数
Widget _createNormalTextField(
String hintTxt,
TextEditingController controller,
TextInputType inputType,
String Function(String) validation,
Function(String) onTextChanged,
int length,
Widget suffixIcon) {
return Container(
margin: EdgeInsets.symmetric(vertical: 8),
child: new TextFormField(
controller: controller,
maxLength: length,
keyboardType: inputType,
validator: validation,
onChanged: onTextChanged,
decoration: InputDecoration(
contentPadding: EdgeInsets.only(bottom: -10.0),
suffixIcon: suffixIcon,
hintText: hintTxt,
)),
);
}
我正在创建几个这样的文本字段:
Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(flex: 2, child: Text("Discount")),
SizedBox(
width: 4,
),
Expanded(
flex: 1,
child: _createNormalTextField(
"", _discountPercentController, TextInputType.number, null,
(txt) {
setState(() {
calculateAmount(txt);
});
}, 2, Text("%")),
),
SizedBox(
width: 4,
),
Expanded(
flex: 2,
child: _createNormalTextField(
"Amount",
_discountAmountController,
TextInputType.number,
null,
(txt) {},
5,
null),
),
],
),
],
);
我使用 '%' 文本作为后缀图标。但它会在中间创建 '%' 并采用我不想要的填充。 我附上了我得到的和我想要的图片:
我明白了:
我想要右下角的后缀图标,比如::
那么有人知道解决方法吗??
【问题讨论】:
标签: android flutter user-interface dart