【问题标题】:flutter: Placing regular widgets on top of CustomPaint canvas颤振:将常规小部件放置在 CustomPaint 画布的顶部
【发布时间】:2020-04-30 07:49:48
【问题描述】:

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

这可能吗?如果是,怎么做?

【问题讨论】:

    标签: user-interface flutter dart custom-painting


    【解决方案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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-10
      • 2018-10-18
      • 1970-01-01
      • 2020-08-10
      • 1970-01-01
      相关资源
      最近更新 更多