我的应用程序主要由 CustomPainted 页面组成。但我很想在画布上放置一两个按钮,例如PopupMenuButton
或。IconButton
这可能吗?如果是,如何?
我的应用程序主要由 CustomPainted 页面组成。但我很想在画布上放置一两个按钮,例如PopupMenuButton
或。IconButton
这可能吗?如果是,如何?
是的,这是可能的。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
.