我有一个图像,我想定位在父高度 * .5,所以例如,如果父高度是500,它应该在250。父高度是动态的,所以它是由size.height * .3或类似的东西设置的。以下是我一直在尝试的代码,但它不起作用:
Positioned(
//mesh
top: topPadding + 40,
child: Container(
width: size.width,
child: Center(
child: Container(
width: size.width * .5,
height:
size.height - size.height * .1 - topPadding - 40,
color: Color.fromARGB(255, 86, 86, 86),
child: Stack(alignment: Alignment.center, children: [
Image.asset('assets/3d_model/Front_Side/mesh.png'),
Positioned(
top: 138, //I WANT IT TO BE PARENT HEIGHT * .1, so when you resize the container the image stays in the right spot
child: Image.asset(
'assets/3d_model/Front_Side/core.png',
width: 67))// And this should be parent width * .whatever, so that it stays relative with the parent container))
])))),
),
1条答案
按热度按时间hsgswve41#
使用FractionallySizedBox和Alignment bottomCenter。
示例代码: