Flutter-如何从小部件(IconButton,CheckBox,FlatButton)中删除默认填充(每个文档48像素) [英] Flutter - how to remove default padding (48 px as per doc) from widgets (IconButton, CheckBox, FlatButton)
问题描述
我正面临着小部件(IconButton,CheckBox,FlatButton)的默认填充问题.我为此问题进行了很多搜索,但没有成功.
I am facing the problem with the default padding of the widgets (IconButton, CheckBox, FlatButton). I have searched a lot for this concern but no success.
在上图中,外部蓝色矩形是这些小部件的实际大小,我必须删除该空间.
In the above image, outer blue rect is the actual size of these widgets and I have to remove that space.
Checkbox(
onChanged: (value) {
setState(() {
_rememberMeFlag = !_rememberMeFlag;
});
},
value: _rememberMeFlag,
activeColor: const Color(0xff00bbff),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
)
及以下是隐藏/显示窗口小部件图标的窗口小部件代码:
and below is the widget code for hide/show widget icon:
new Container(
child: TextFormField(
decoration: InputDecoration(
labelText: "Password",
suffixIcon: Padding(
padding: EdgeInsetsDirectional.zero,
child: GestureDetector(
child: Icon(
hidePassword ? Icons.visibility : Icons.visibility_off,
size: 20.0,
color: Colors.black,
),
),
),
contentPadding: const EdgeInsets.only(
left: 0.0, top: 6.0, bottom: 6.0, right: 0.0),
),
obscureText: !hidePassword,
maxLength: 20,
),
)
我也尝试设置容器的大小,但是没有运气.还尝试了小部件的padding属性,但没有成功.
I have tried to set the container size too but no luck. Also tried the padding properties of the widgets but no success.
是否可以从这些小部件中删除这些多余的间距?
Is there any way to remove these extra spacing from these widgets?
推荐答案
将CheckBox
包裹在SizedBox
内将调整复选框的填充大小
wrap your CheckBox
inside SizedBox
will resize the padding of the check box
SizedBox(
height: 24.0,
width: 24.0,
child: Checkbox(...),
)
这篇关于Flutter-如何从小部件(IconButton,CheckBox,FlatButton)中删除默认填充(每个文档48像素)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!