【发布时间】:2020-07-04 14:52:56
【问题描述】:
我尝试在屏幕上对齐三个小部件以相互引用。
我有一个金色边框,我想将其设置为我的背景,中心的轮子和轮子的中心,这也是一个单独的资产。
我已经使用 MediaQuery 对齐了资产,但是每次我在不同的设备上调试它时,MediaQuery 都会有一些差异,并且 alignmnet 不正确。 这就是我调用我的小部件的方式:
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
//this is for the GOLDEN BORDER
Positioned(
top: MediaQuery.of(context).size.height * 0.082,
child: Image.asset(
'assets/app/border3.png',
height: MediaQuery.of(context).size.width,
)),
//This is the WHEEL
Column(
children: <Widget>[
SizedBox(height: MediaQuery.of(context).size.height * 0.344),
Container(
//color: Theme.of(context).primaryColor.withAlpha(180),
child: Center(
child: Winwheel(
handleCallback: ((handler) {
ctrl = handler;
}),
textFontFamily: 'Netflix',
controller: ctrl,
numSegments: 3,
outerRadius: MediaQuery.of(context).size.height * 0.41 / 2,
innerRadius: 28,
strokeStyle: Colors.white,
textFontSize: 20.0,
textFillStyle: Colors.white,
textFontWeight: FontWeight.bold,
textAlignment: WinwheelTextAlignment.center,
textOrientation: WinwheelTextOrientation.horizontal,
wheelImage: 'assets/app/spin2.png',
drawMode: WinwheelDrawMode.code,
drawText: true,
imageOverlay: false,
textMargin: 0,
pointerAngle: 0,
pointerGuide: PointerGuide(
display: true,
),
segments: <Segment>[
Segment(
textFontFamily: 'Netflix',
fillStyle: Color(0xff9b57fc),
textFillStyle: Colors.white,
text: '400',
strokeStyle: Colors.transparent),
Segment(
textFontFamily: 'Netflix',
fillStyle: Color(0xff17a8f9),
textFillStyle: Colors.white,
text: '400',
strokeStyle: Colors.transparent,
),
Segment(
textFontFamily: 'Netflix',
fillStyle: Colors.pink,
textFillStyle: Colors.white,
text: '900',
strokeStyle: Colors.transparent,
),
Segment(
textFontFamily: 'Netflix',
fillStyle: Color(0xffef225b),
textFillStyle: Colors.white,
text: '500',
strokeStyle: Colors.transparent,
),
],
pins: Pin(
visible: false,
number: 16,
margin: 6,
// outerRadius: 5,
fillStyle: Colors.transparent,
),
animation: WinwheelAnimation(
type: WinwheelAnimationType.spinToStop,
spins: 4,
duration: const Duration(
seconds: 15,
),
callbackFinished: (int segment) {
setState(() {
isPlaying = false;
});
print('animation finished');
print(segment);
},
callbackBefore: () {
setState(() {
isPlaying = true;
});
},
),
),
),
),
],
),
//This is the GOLDEN CENTER
Positioned(
top: MediaQuery.of(context).size.height * 0.285,
left: MediaQuery.of(context).size.width * 0.359,
child: Image.asset('assets/app/center.png',
height: MediaQuery.of(context).size.height * 0.16)),
],
),
);
}
我正在为 Spinning wheel 使用 winwheel 依赖项。 这就是最终输出的样子。尽管在图像中看起来不错,但它并未在所有设备中正确对齐
【问题讨论】:
标签: flutter user-interface dart