【发布时间】:2020-04-30 07:49:48
【问题描述】:
我的应用主要由 CustomPainted 页面组成。但我想在画布上放置一两个按钮,例如 PopupMenuButton 或 IconButton。
这可能吗?如果是,怎么做?
【问题讨论】:
标签: user-interface flutter dart custom-painting
我的应用主要由 CustomPainted 页面组成。但我想在画布上放置一两个按钮,例如 PopupMenuButton 或 IconButton。
这可能吗?如果是,怎么做?
【问题讨论】:
标签: user-interface flutter dart custom-painting
是的,这是可能的。 CustomPaint 接受 child 属性,该属性可用于在其上放置小部件,例如:
CustomPaint(
painter: _RadialPainter(
color: Theme.of(context).primaryColor,
completedPercentage: progress.completed,
),
child: Center(
child: Text(
'${progress.left}',
style: Theme.of(context).textTheme.headline4,
),
),
);
注意_RadialPainter 扩展了CustomPainter。
【讨论】: