0

我的应用程序主要由 CustomPainted 页面组成。但我很想在画布上放置一两个按钮,例如PopupMenuButton或。IconButton

这可能吗?如果是,如何?

4

1 回答 1

1

是的,这是可能的。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.

于 2020-04-30T09:14:56.573 回答