user-interface - 如何在脚手架上对齐背景图像?

标签 user-interface flutter dart

我有一个页面,我要在此处在脚手架上的车轮上设置此金色边框。
这是我的代码:

 Widget spinningWheel(context) {
    double realWidth = MediaQuery.of(context).size.width;
    return Container(
      decoration: BoxDecoration(color: Colors.transparent),
      //color: Theme.of(context).primaryColor.withAlpha(180),
      child: Align(
        alignment: Alignment.topCenter,
        child: Spinwheel(
          shouldDrawCenterPiece: true,
          wheelPaint: Paint()..color = Colors.red,
          sectorDividerPaint: Paint()..color = Colors.black,
          centerPiecePaint: Paint()..color = Colors.black,
          items: items,
          size: realWidth * 0.9,
          onChanged: (val) {
            if (this.mounted) setState(() {});
          },
          select: select,
          shouldDrawDividers: true,
          wheelOrientation: pi / 8,
          autoPlay: false,
          hideOthers: false,
          shouldDrawBorder: false,
          shouldHighlight: false,
        ),
      ),
    );
  }

这是我正在使用的依赖项:https://pub.dev/packages/flutter_spinwheel

这就是我的方向盘
enter image description here

这是我要插入的边框:enter image description here

最佳答案

尝试Stack Widget并相应地设置对齐方式,这是演示,并确保您使用的是透明背景图像:

 @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    return Scaffold(
      body: Stack(
        children: <Widget>[
          Align(
            alignment: Alignment.topCenter,
            child: new Image.asset(
              'assets/yellow_circle.jpg',
              width: size.width,
              height: size.height/2,
              fit: BoxFit.fill,
            ),
          ),
          Align(
            alignment: Alignment.topCenter,
            child: new Image.asset(
              'assets/red_circle.png',
              width: size.width,
              height: size.height/2,
              fit: BoxFit.fill,
            ),
          ),
        ],
      ),
    );
  }
}

enter image description here

关于user-interface - 如何在脚手架上对齐背景图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62289694/

相关文章:

mysql - 数据库设计: 3 types of users, 分开还是一张表?

java - 在 Java 中绘制带尖角的带边框路径

dart - 转换的纪元时间比模拟器提前 5 小时

flutter - 如何像在音乐播放器中一样在Flutter中创建自定义通知并处理按钮单击

dart - Tracing.dart 的 Angular Dart 导入错误

webserver - 我将如何在Windows服务器上运行Dart VM?

java - 检查(多个 Jbutton 中的)哪个 Jbutton 被单击

user-interface - Oneiric Ubuntu Server Cloud Guest 11.10 (Ocelot) 如何在亚马逊 AWS 中远程桌面

flutter - 需要帮助调整 Flutter AppBar 的大小以适合 4 行文本并且

Flutter:带扩展磁贴的抽屉导航