如果email.png前缀失去了对这一领域的关注,它就会消失。我曾尝试使用prefixIcon,但在这种情况下还是可以的,但是如果我使用prefixIcon,则无法调整图像的大小。
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);
},
),
答案 0 :(得分:2)
之所以起作用,是因为以前我将图标小部件与prefix:
属性一起使用,而该属性应该是prefixIcon:
属性
TextFormField(
decoration: InputDecoration(
prefixIcon: SizedBox(
child: Center(
widthFactor: 0.0,
child: Image.asset(
'assets/email.png',
width: 20,
height: 20,
),
),
),
),
)