我想要在LinearGradient容器内的左下方对齐文本,如图所示,但是由于我将列小部件作为容器的子级放置,因此将其放置在中间。因此,我需要为图像中的结果编辑的正确代码是什么。
main.dart
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: <Widget>[
Container(
width: 300,
height: 220,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Image(
fit: BoxFit.cover,
image: AssetImage('assets/image1.png'),
),
Positioned(
left: 0,
bottom: 0,
child: Container(
width: 285,
height: 110,
margin: EdgeInsets.only(left:8, bottom: 30),
padding: EdgeInsets.only(),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
gradient: LinearGradient(
begin: FractionalOffset.center,
end: FractionalOffset.bottomCenter,
colors: [
const Color(0XFF000000).withOpacity(.0),
const Color(0XFF000000).withOpacity(0.8),
],
)
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Jerusalem",
style: TextStyle(
fontFamily: 'AirbnbCerealBold',
fontSize: 28,
fontWeight: FontWeight.bold,
color: Colors.white),
),
Text(
"1,243 Place",
style: TextStyle(
fontFamily: 'AirbnbCerealBook',
fontSize: 14,
color: Colors.white),
),
],
),
),
),
],
),
),
],
),
),
答案 0 :(得分:3)
您尝试过
mainAxisAlignment:MainAxisAlignment.end,
带有列
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
有效。