[英]How do I align a background Image on my Scaffold?
我有一個頁面,我想在我的腳手架上的輪子周圍設置這個金色邊框。 這是我的代碼:
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
嘗試 Stack Widget 並相應地設置 alignment 這是演示並確保您使用的是透明背景圖像:
@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,
),
),
],
),
);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.