Flutter TextFormField的前缀图像在字段不再聚焦后消失
如果在字段上失去焦点,email.png前缀将消失。我曾尝试使用prefixIcon,在这种情况下效果不错,但如果使用prefixIcon,则无法调整图像大小Flutter TextFormField的前缀图像在字段不再聚焦后消失,flutter,dart,Flutter,Dart,如果在字段上失去焦点,email.png前缀将消失。我曾尝试使用prefixIcon,在这种情况下效果不错,但如果使用prefixIcon,则无法调整图像大小 TextFormField( decoration: InputDecoration( //textInputDecoration.copyWith(hintText: 'Password'), prefix: Paddin
TextFormField(
decoration: InputDecoration(
//textInputDecoration.copyWith(hintText: 'Password'),
prefix: Padding(
padding: EdgeInsets.fromLTRB(5, 0, 10, 0),
child: Image.asset(
'assets/email.png',
width:20,
height:20,
),
),
hintText: 'Email',
hintStyle: TextStyle(
color: HexColor("#1A1A1A").withOpacity(0.2),
fontSize: 14,
),
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(40.0),
borderSide: BorderSide(color: HexColor("#1A1A1A").withOpacity(0.2)),
),
),
validator: (val) => val.isEmpty ? 'Enter an email' : null,
onChanged: (val) {
setState(() => email = val);
},
),
这是有效的,因为之前我使用了带有
前缀:
属性的图标小部件,它应该是前缀:
属性
TextFormField(
decoration: InputDecoration(
prefixIcon: SizedBox(
child: Center(
widthFactor: 0.0,
child: Image.asset(
'assets/email.png',
width: 20,
height: 20,
),
),
),
),
)
这是有效的,因为之前我使用了带有
前缀:
属性的图标小部件,它应该是前缀:
属性
TextFormField(
decoration: InputDecoration(
prefixIcon: SizedBox(
child: Center(
widthFactor: 0.0,
child: Image.asset(
'assets/email.png',
width: 20,
height: 20,
),
),
),
),
)
无法调整前缀的大小。你可以调整textformfield的大小。只需包装在一个容器中。但我不想让整个textformfield变小,我说是prefixIcon让它工作了,而不是我想要的,因为在assetImage上使用图标显然是错误的。你想要什么?您的问题不清楚。要使前缀assetImage在我单击另一个FormField后保持不变,您不能调整前缀大小。你可以调整textformfield的大小。只需包装在一个容器中。但我不想让整个textformfield变小,我说是prefixIcon让它工作了,而不是我想要的,因为在assetImage上使用图标显然是错误的。你想要什么?您的问题不清楚。要在单击另一个FormField后保留前缀assetImage,我想使用我自己的电子邮件图像,我已更新了答案。如果它不起作用,请告诉我。我想使用我自己的电子邮件图像我已经更新了答案。如果不起作用,请告诉我。