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下面的答案是否解决了您的问题?