flutter:将常规小部件放置在 CustomPaint canvas 之上
flutter: Placing regular widgets on top of CustomPaint canvas
我的应用程序主要由 CustomPainted 页面组成。但我喜欢在 canvas 之上放置一两个按钮,例如 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
。
我的应用程序主要由 CustomPainted 页面组成。但我喜欢在 canvas 之上放置一两个按钮,例如 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
。