I want to customize the Icon on the right of TextField, but the size of the Icon cannot be changed after using Image. If I use Icon, I can change it, why? What can I do to use custom images and resize them?
new TextField(
decoration: InputDecoration(
hintText: '请输入密码',
suffixIcon: new GestureDetector(
onTap: () {},
child: new Container(
color: Colors.cyan,
child: Image(
image: AssetImage(
'images/login/icon_show_sel.png',
),
height: 20,
width: 20,
),
),
),
),
),
You can now resize the suffixIcon with suffixIconConstraints
decoration: InputDecoration(
suffixIconConstraints: BoxConstraints(
minHeight: 24,
minWidth: 24
),
suffixIcon: Icon(Icons.arrow_drop_down_sharp, color: AppColors.heather),);
This problem has been solved.
Add the padding in the Container.
The following code:
new TextField(
decoration: InputDecoration(
hintText: '请输入密码',
suffixIcon: new GestureDetector(
onTap: () {},
child: new Container(
padding: EdgeInsets.symmetric(vertical: 10),
child: Image(
image: AssetImage(
'images/login/icon_show_sel.png',
),
height: 20,
width: 20,
),
),
),
),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With