Flutter 中 TextFormField 的 prefixIcon 的调整大小(高度和宽度)不起作用
Resize (height and width) of an prefixIcon of TextFormField in Flutter is not working
final password = TextFormField(
autofocus: false,
obscureText: true,
decoration: InputDecoration(
hintText: 'Password',
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
prefixIcon: new ImageIcon(
new AssetImage('assets/ic_email.png'),
size: 15.0,
),
),
);
我已将大小设置为 15.0,但没有任何变化,所以请指导我,我哪里做错了?
刚刚通过在Image.asset中设置属性得到解决方案,请尝试以下方法
final password = TextFormField(
autofocus: false,
obscureText: true,
decoration: InputDecoration(
hintText: 'Password',
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
prefixIcon: new IconButton(
icon: new Image.asset('assets/ic_email.png',width: 15.0,height: 15.0,),
onPressed: null,
),
),
);
你可以这样做
TextField(
textCapitalization: TextCapitalization.sentences,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
border: InputBorder.none,
focusedBorder: InputBorder.none,
prefixIcon: IconButton(
icon: Image.asset(
'assets/your_image_here',),
onPressed: () {},
),
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
hintText: AppString.searchName,
),
)
final password = TextFormField(
autofocus: false,
obscureText: true,
decoration: InputDecoration(
hintText: 'Password',
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
prefixIcon: new ImageIcon(
new AssetImage('assets/ic_email.png'),
size: 15.0,
),
),
);
我已将大小设置为 15.0,但没有任何变化,所以请指导我,我哪里做错了?
刚刚通过在Image.asset中设置属性得到解决方案,请尝试以下方法
final password = TextFormField(
autofocus: false,
obscureText: true,
decoration: InputDecoration(
hintText: 'Password',
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
prefixIcon: new IconButton(
icon: new Image.asset('assets/ic_email.png',width: 15.0,height: 15.0,),
onPressed: null,
),
),
);
你可以这样做
TextField(
textCapitalization: TextCapitalization.sentences,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
border: InputBorder.none,
focusedBorder: InputBorder.none,
prefixIcon: IconButton(
icon: Image.asset(
'assets/your_image_here',),
onPressed: () {},
),
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
hintText: AppString.searchName,
),
)