How do I remove content padding from TextField?

后端 未结 10 1826
深忆病人
深忆病人 2021-02-05 01:28

I am new to flutter and I am creating login form, for that I have used TextField and added prefix icon but I am getting some extra spaces in between textfields (user id and pin

10条回答
  •  自闭症患者
    2021-02-05 02:23

    That prefixIcon has already contained the padding of 12.0 according to documentation. So you don't need to provide extra padding.

    See this below explanation & code which you can find in input_decorator.dart.

    The prefix icon is constrained with a minimum size of 48px by 48px, but can be expanded beyond that. Anything larger than 24px will require additional padding to ensure it matches the material spec of 12px padding between the left edge of the input and leading edge of the prefix icon. To pad the leading edge of the prefix icon:

    prefixIcon: Padding(
         padding: const EdgeInsetsDirectional.only(start: 12.0),
         child: myIcon, // icon is 48px widget.
    )
    

    I hope it will help.

提交回复
热议问题