flutter - Flutter:使用 CircleBorder 填充背景的 IconButton - 如何设置大小
问题描述
Container(
child: Center(
child: Ink(
decoration: const ShapeDecoration(
color: Colors.lightGreen,
shape: CircleBorder(),
),
child: IconButton(
icon: Icon(Icons.add),
color: Colors.white,
onPressed: () {},
),
),
),
),
Text('KG : $_volume'),
Container(
width: 40,
height: 40,
child: Center(
child: Ink(
decoration: const ShapeDecoration(
color: Colors.lightGreen,
shape: CircleBorder(),
),
child: IconButton(
icon: Icon(Icons.add),
color: Colors.white,
onPressed: () {},
),
),
),
),
这将创建具有填充背景的 IconButton,如附加图像中所示。
我想在这里减小圆圈(CircleBorder)的大小。我如何有效地做到这一点?
解决方案
小IconButton
部件具有默认填充尝试删除它会起作用
试试这个方法
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: 40,
height: 40,
child: GestureDetector(
onTap: (){
},
child: Ink(
decoration: const ShapeDecoration(
color: Colors.lightGreen,
shape: CircleBorder(),
),
child: Icon(Icons.add,color: Colors.white,)
),
),
),
Text('KG : 5'),
Container(
width: 40,
height: 40,
child: GestureDetector(
onTap: (){
},
child: Ink(
decoration: const ShapeDecoration(
color: Colors.lightGreen,
shape: CircleBorder(),
),
child: Icon(Icons.add,color: Colors.white,)
),
),
),
],
),
另一种方式
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: 40,
height: 40,
decoration: BoxDecoration(shape: BoxShape.circle,
color: Colors.lightGreen),
child: GestureDetector(
onTap: () {
debugPrint('Clicked');
},
child: Icon(
Icons.add,
color: Colors.white,
),
),
),
Text('KG : 5'),
Container(
width: 40,
height: 40,
decoration: BoxDecoration(shape: BoxShape.circle,
color: Colors.lightGreen),
child: GestureDetector(
onTap: () {
debugPrint('Clicked');
},
child: Icon(
Icons.add,
color: Colors.white,
),
),
),
],
),
输出
推荐阅读
- r - 用于查看 df 的元素是否包含在 List 内的 df 中的逻辑向量
- mysql - MySQL:仅匹配键字符串表中字符串中的精确字符串
- react-native - 如何将文本组件作为参数传递到我的函数中以确定按下了哪个元素?
- c# - 如何通过特定源 C# 获取 Windows 事件日志列表
- angular - 为角度反应形式添加自定义验证时出错
- c - 该程序是否正确计算 CRC?
- python - 从 Pandas groupby 对象中收集系列
- typescript - connect-redis.redis 和 ioredis.redis 类型不兼容
- python - 在 django rest 框架中缓存查询集?
- python - 将协程扔到事件循环而不阻塞