Flutter-调整自定义按钮点击区域
Flutter- adjust the custom button tap area
Widget customButton() {
return Container(
child: InkWell(
onTap: () {},
child: Container(
height: 100,
width: 100,
decoration: BoxDecoration(
color: Colors.amber,
shape: BoxShape.circle,
),
child: Icon(Icons.auto_fix_normal),
),
),
);
}
我正在尝试使用墨水池创建自定义按钮,但按钮可以从按钮外部点击。如何调整按钮点击区域?
使用 customBorder: CircleBorder()
,在 InkWell 上修复了飞溅效果,但为了使其正常工作,我正在扩展代码段。
Widget customButton() {
return Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
child: Material(
color: Colors.orange,
shape: const CircleBorder(),
child: InkWell(
splashColor: Colors.black,
onTap: () {},
customBorder: const CircleBorder(),
child: Ink(
decoration: const BoxDecoration(shape: BoxShape.circle),
height: 100,
width: 100,
child: const Icon(Icons.holiday_village),
),
),
),
);
}
Widget customButton() {
return Container(
child: InkWell(
onTap: () {},
child: Container(
height: 100,
width: 100,
decoration: BoxDecoration(
color: Colors.amber,
shape: BoxShape.circle,
),
child: Icon(Icons.auto_fix_normal),
),
),
);
}
我正在尝试使用墨水池创建自定义按钮,但按钮可以从按钮外部点击。如何调整按钮点击区域?
使用 customBorder: CircleBorder()
,在 InkWell 上修复了飞溅效果,但为了使其正常工作,我正在扩展代码段。
Widget customButton() {
return Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
child: Material(
color: Colors.orange,
shape: const CircleBorder(),
child: InkWell(
splashColor: Colors.black,
onTap: () {},
customBorder: const CircleBorder(),
child: Ink(
decoration: const BoxDecoration(shape: BoxShape.circle),
height: 100,
width: 100,
child: const Icon(Icons.holiday_village),
),
),
),
);
}