gpt4 book ai didi

flutter - SliverAppBar 滚动时 flexibleSpace 内的图标不隐藏

转载 作者:行者123 更新时间:2023-12-04 02:39:40 30 4
gpt4 key购买 nike

我在 flexibleSpace 中有 'Next' 和 'Prev' 按钮,如下所示,'Next' 和 'Prev' 按钮的文本确实隐藏在滚动条上,但前进和后退箭头会隐藏不隐藏。我希望它们在滚动时隐藏。

enter image description here

这是我的代码,

            SliverAppBar(
backgroundColor: selectedColor ?? Colors.blue,
expandedHeight: 112,
snap: true,
pinned: false,
floating: true,
forceElevated: true,
actions: <Widget>[
IconButton(
icon: Icon(Icons.event),
onPressed: () {
DateTime now = DateTime.now();
_selectDate(context, now);
})
],
flexibleSpace: selectedTitle != null ? SafeArea(
child: Column(
children: <Widget>[
Container(
height: kToolbarHeight,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
selectedTitle?.toUpperCase() ?? '',
style: Theme
.of(context)
.textTheme
.title
.copyWith(fontSize: 16, color: Colors.white),
),
SizedBox(
height: 2,
),
isWeekly
? SizedBox(
height: 0,
width: 0,
)
: Text(
displayDate ?? '',
style: Theme
.of(context)
.textTheme
.caption
.copyWith(fontSize: 10, color: Colors.white),
),
SizedBox(
height: 2,
),
Text(
selectedParshaNodeModel?.parshaName ?? '',
style: Theme
.of(context)
.textTheme
.subtitle
.copyWith(fontSize: 14, color: Colors.white),
),
],
),
),
Expanded(
child: Container(
height: kToolbarHeight,
width: MediaQuery
.of(context)
.size
.width,
color: Colors.white,
child: Row(
children: <Widget>[
Expanded(
child:
FlatButton(
onPressed: () {}
,
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: <Widget>[
Icon(Icons.arrow_back,
color: Colors.grey),
Text(
'Prev',
style: Theme
.of(context)
.textTheme
.subhead
.copyWith(color: Colors.grey),
)
],
))),
Expanded(
child:
FlatButton(
onPressed: (){},
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Text('Next',
style: Theme
.of(context)
.textTheme
.subhead
.copyWith(color: Colors.grey)),
Icon(
Icons.arrow_forward,
color: Colors.grey,
),
],
)))
],
),
),
)
],
),
) : Container(),
),

最佳答案

发生这种情况是因为箭头溢出了按钮的边界。添加 clipBehavior: Clip.hardEdge 应该可以解决您的问题:

child: FlatButton(
clipBehavior: Clip.hardEdge,
onPressed: () {},
child: Row(
...Your Arrow and Text
),
),

关于flutter - SliverAppBar 滚动时 flexibleSpace 内的图标不隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59973123/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com