这是我的应用程序的主页,我在这里使用列来显示页面的内容:包含当天动漫的容器和故事滚动容器。
默认情况下,一切都很好,但当我滚动故事(ListView(时,会出现一个裂缝(请参阅附件(,因此渐变不会到达终点。问题出在哪里?
屏幕截图:
滚动之前
滚动后
代码片段:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 510,
width: double.infinity,
child: Stack(fit: StackFit.expand, children: [
Positioned.fill(
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
'https://img5.goodfon.ru/wallpaper/nbig/3/59/shingeki-no-kyojin-ataka-titanov-parni-eren-levi.jpg'),
fit: BoxFit.cover)),
)),
Align(
alignment: Alignment.bottomCenter,
child: Container(
width: double.infinity,
height: 510,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0x15161a),
Color(0x2d15161a),
Color(0xff18191e)
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter)),
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('Вторжение титанов',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 40,
)),
SizedBox(height: 5),
Text(
'Attack of titans',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 20,
),
),
SizedBox(height: 80),
Row(
children: [
Text(
'приключения',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
SizedBox(
width: 16,
),
Text(
'2021',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
SizedBox(
width: 16,
),
Text(
'18+',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
],
),
SizedBox(
height: 10,
)
]))))
])),
SizedBox(
height: 15,
),
Container(
height: 100,
child: ListView(
physics: BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
children: [
Row(
children: [
SizedBox(
width: 11,
),
Column(
children: [
CircleAvatar(
radius: 37,
backgroundColor: Color(0xffdddddd),
child: CircleAvatar(
radius: 36,
backgroundColor: Color(0xff1e1f23),
child: CircleAvatar(
radius: 34,
backgroundImage: NetworkImage(
'https://picsum.photos/200/300'),
),
)),
SizedBox(
height: 9,
),
Text(
'Новое',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 11,
),
),
],
),
SizedBox(
width: 9,
),
Column(
children: [
CircleAvatar(
radius: 37,
backgroundColor: Color(0xffdddddd),
child: CircleAvatar(
radius: 36,
backgroundColor: Color(0xff1e1f23),
child: CircleAvatar(
radius: 34,
backgroundImage: NetworkImage(
'https://picsum.photos/200/300'),
),
)),
SizedBox(
height: 9,
),
Text(
'Новое',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 11,
),
),
],
),
SizedBox(
width: 9,
),
Column(
children: [
CircleAvatar(
radius: 37,
backgroundColor: Color(0xffdddddd),
child: CircleAvatar(
radius: 36,
backgroundColor: Color(0xff1e1f23),
child: CircleAvatar(
radius: 34,
backgroundImage: NetworkImage(
'https://picsum.photos/200/300'),
),
)),
SizedBox(
height: 9,
),
Text(
'Новое',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 11,
),
),
],
),
SizedBox(
width: 9,
),
Column(
children: [
CircleAvatar(
radius: 37,
backgroundColor: Color(0xffdddddd),
child: CircleAvatar(
radius: 36,
backgroundColor: Color(0xff1e1f23),
child: CircleAvatar(
radius: 34,
backgroundImage: NetworkImage(
'https://picsum.photos/200/300'),
),
)),
SizedBox(
height: 9,
),
Text(
'Новое',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 11,
),
),
],
),
SizedBox(
width: 9,
),
Column(
children: [
CircleAvatar(
radius: 37,
backgroundColor: Color(0xffdddddd),
child: CircleAvatar(
radius: 36,
backgroundColor: Color(0xff1e1f23),
child: CircleAvatar(
radius: 34,
backgroundImage: NetworkImage(
'https://picsum.photos/200/300'),
),
)),
SizedBox(
height: 9,
),
Text(
'Новое',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 11,
),
),
],
),
SizedBox(
width: 9,
),
Column(
children: [
CircleAvatar(
radius: 37,
backgroundColor: Color(0xffdddddd),
child: CircleAvatar(
radius: 36,
backgroundColor: Color(0xff1e1f23),
child: CircleAvatar(
radius: 34,
backgroundImage: NetworkImage(
'https://picsum.photos/200/300'),
),
)),
SizedBox(
height: 9,
),
Text(
'Новое',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 11,
),
),
],
),
],
)
]),
),
SizedBox(
height: 37,
),
Padding(
padding: EdgeInsets.fromLTRB(11, 0, 0, 11),
child: Column(
children: [
Text(
'Новинки',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 30,
),
),
],
),
),
],
)
在Positioned.fill()
中向Container()
添加margin: EdgeInsets.only(bottom:1)
解决了问题。
由@ChiragBargoojar 提供的解决方案