Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 如何在脚手架上对齐背景图像?_User Interface_Flutter_Dart - Fatal编程技术网

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

User interface 如何在脚手架上对齐背景图像?,user-interface,flutter,dart,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).primary

我有一个页面,我想在脚手架上的轮子周围设置这个金色边框。 这是我的代码:

 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,
        ),
      ),
    );
  }
这是我正在使用的依赖项:

这就是我的轮子的样子


这是我要插入的边框:

尝试堆栈小部件并相应地设置对齐这是演示,确保您使用的是透明背景图像:

 @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,
            ),
          ),
        ],
      ),
    );
  }
}
@覆盖
小部件构建(构建上下文){
Size Size=MediaQuery.of(context).Size;
返回脚手架(
主体:堆栈(
儿童:[
对齐(
对齐:alignment.topCenter,
子:新建Image.asset(
“资产/黄色圆圈.jpg”,
宽度:size.width,
高度:size.height/2,
fit:BoxFit.fill,
),
),
对齐(
对齐:alignment.topCenter,
子:新建Image.asset(
“assets/red_circle.png”,
宽度:size.width,
高度:size.height/2,
fit:BoxFit.fill,
),
),
],
),
);
}
}

尝试使用stack Widget下面的答案是否解决了您的问题?