Flutter中TextFormField的prefixIcon的大小调整(高度和宽度)不起作用

时间:2018-11-28 12:37:37

标签: flutter flutter-layout

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,但没有任何变化,所以请指导我,我在哪里做错了?

1 个答案:

答案 0 :(得分: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,
    ),
  ),
);