[我想要的是让背景图像占据屏幕的一半以下,并在顶部添加一个Card Widget。从这里好。但是,当我插入另一个Card Widget时,它会改变位置,无法修复。
return SafeArea(
child: Container(
child: Column(
children: [
Stack(alignment: Alignment(0, 5.4), children: [
ProfileBackgroundImage(
backgroundImage:
'https://images.unsplash.com/photo-1580331451062-99ff652288d7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80',
),
ProfileMainBubble(
name: 'Laia Montés',
photoProfile:
'https://images.unsplash.com/photo-1578680671705-0965e325b2ba?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1233&q=80',
profession: 'Singer and Guitarrist',
description:
'I’m a musician who loves Pop and Rock. 🤘 Currently studying for being a lawyer, but what I truly want is to sing in the shower.',
isFollowing: isFollowing)
]),
StatisticsBubble(
uploads: 36, reproductions: 2000000, hearts: 128000),
],
),
),
);
问题是我需要设置ProfileMainBubble
和StatisticsBubble
的位置,以便内容可以更改。那么,有没有Stack
我都可以解决吗?
将其作为子元素放在Positioned()小部件内:
Positioned(
top: *modify here double values*,
bottom: same with top and so on with left and right,
child: ProfileBackgroundImage(
backgroundImage:
'https://images.unsplash.com/photo-1580331451062-99ff652288d7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80',
)
)
注意位置的窗口小部件将仅在Stack内部工作。
Widget build(BuildContext context) {
return Container(
child: Align(
alignment: FractionalOffset(0.5,0.5),
child: Container(),
)
);
}