Anonymous
Не в состоянии нажать на кнопки действий на SliverpersistentHeader, когда пользователь прокручивает
Сообщение
Anonymous » 28 апр 2025, 11:46
Я строю приложение Flutter, которое использует SliverpersistentHeader , и я добавил некоторое наложение кнопок действия, которое SliverPersistentHeader . Но в приложении возникла проблема, в которой кнопки действий не могут нажать, когда пользователь прокручивается. Я не хочу использовать SliverAppbar , потому что я не могу положить накладку карты. Таким образом, я использую SliverPersiStentHeader вместо этого, потому что он способен поместить наложение виджета карты. Sliverpersistentheader . Так что пользователь сможет увидеть кнопки действий при прокрутке. Но, к сожалению, я не могу нажать на эту кнопку действия. < /P>
ниже приведен код. Обратите внимание, что я обернулся SliverRpersiStenheader InsideScrollview и defaultTabController
Код: Выделить всё
SliverPersistentHeader(
delegate: MySliverAppBar(
/// pass data by here
expandedHeight: 230,
),
pinned: true,
floating: true,
),
Вот SliverpersistentHeaderDelegate Class.
Код: Выделить всё
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
const Color _devider_color = Color(0xff425262);
final _actionButtonColor = Theme.of(context).cardColor.withOpacity(0.7);
return Stack(
fit: StackFit.expand,
overflow: Overflow.visible,
children: [
Image.network(
clanProfile.mainImage == null ? _clanLogo : clanProfile.mainImage,
fit: BoxFit.cover,
),
Positioned(
top: 0,
left: 12,
child: InkWell(
onTap: () {
Navigator.pop(context);
},
child: SafeArea(
child: Container(
height: 50,
width: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
color: _actionButtonColor,
),
child: Icon(Icons.arrow_back_ios)),
),
),
),
Positioned(
top: 0,
right: 12,
child: SafeArea(
child: Row(
children: [
InkWell(
onTap: () {
Navigator.of(context).pushNamed(MembersListPage.routeName,
arguments: MembersListPageArguments(
members: members,
masterId: masterId,
));
},
child: Container(
height: 50,
width: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
color: _actionButtonColor,
),
child: Icon(Icons.info),
),
),
PaddingSmall(isHorizontal: true),
Visibility(
visible: isClanMaster && true,
child: Row(
children: [
InkWell(
onTap: () {
Navigator.pushNamed(
context, EditClanPagePage.routeName,
arguments: EditClanPagePageArgument(
clanPageModel: clanProfile))
.then((Object message) {
if (message == 'Success') {
load();
}
});
},
child: Container(
height: 50,
width: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
color: _actionButtonColor,
),
child: Icon(Icons.edit)),
),
PaddingSmall(isHorizontal: true),
InkWell(
onTap: () {
generateInviteLink().then((value) {
_showInviteDialogue(
context: context, message: value);
});
},
child: Container(
height: 50,
width: 100,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
color: _actionButtonColor,
),
child: Text(
'Invite ',
style: TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.bold),
),
),
),
],
),
),
],
),
),
),
Center(
child: Opacity(
opacity: shrinkOffset / expandedHeight,
child: Text(
name,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 23,
),
),
),
),
Positioned(
// top: 60,
top: expandedHeight / 1.3 - shrinkOffset,
left: constants.padding_large,
right: constants.padding_large,
child: _buildUserDetailOverlayContainer(),
),
),
),
],
);
}
Причина, по которой я использовал SliverpersistentHeader over sliverappbar , потому что я хочу положить наложение карты.>
Подробнее здесь:
https://stackoverflow.com/questions/644 ... er-scrolls
1745829999
Anonymous
Я строю приложение Flutter, которое использует SliverpersistentHeader , и я добавил некоторое наложение кнопок действия, которое SliverPersistentHeader . Но в приложении возникла проблема, в которой кнопки действий не могут нажать, когда пользователь прокручивается. Я не хочу использовать SliverAppbar , потому что я не могу положить накладку карты. Таким образом, я использую SliverPersiStentHeader вместо этого, потому что он способен поместить наложение виджета карты. Sliverpersistentheader . Так что пользователь сможет увидеть кнопки действий при прокрутке. Но, к сожалению, я не могу нажать на эту кнопку действия. < /P> ниже приведен код. Обратите внимание, что я обернулся SliverRpersiStenheader InsideScrollview и defaultTabController [code]SliverPersistentHeader( delegate: MySliverAppBar( /// pass data by here expandedHeight: 230, ), pinned: true, floating: true, ), [/code] Вот SliverpersistentHeaderDelegate Class. [code]@override Widget build( BuildContext context, double shrinkOffset, bool overlapsContent) { const Color _devider_color = Color(0xff425262); final _actionButtonColor = Theme.of(context).cardColor.withOpacity(0.7); return Stack( fit: StackFit.expand, overflow: Overflow.visible, children: [ Image.network( clanProfile.mainImage == null ? _clanLogo : clanProfile.mainImage, fit: BoxFit.cover, ), Positioned( top: 0, left: 12, child: InkWell( onTap: () { Navigator.pop(context); }, child: SafeArea( child: Container( height: 50, width: 50, decoration: BoxDecoration( borderRadius: BorderRadius.circular(25), color: _actionButtonColor, ), child: Icon(Icons.arrow_back_ios)), ), ), ), Positioned( top: 0, right: 12, child: SafeArea( child: Row( children: [ InkWell( onTap: () { Navigator.of(context).pushNamed(MembersListPage.routeName, arguments: MembersListPageArguments( members: members, masterId: masterId, )); }, child: Container( height: 50, width: 50, decoration: BoxDecoration( borderRadius: BorderRadius.circular(25), color: _actionButtonColor, ), child: Icon(Icons.info), ), ), PaddingSmall(isHorizontal: true), Visibility( visible: isClanMaster && true, child: Row( children: [ InkWell( onTap: () { Navigator.pushNamed( context, EditClanPagePage.routeName, arguments: EditClanPagePageArgument( clanPageModel: clanProfile)) .then((Object message) { if (message == 'Success') { load(); } }); }, child: Container( height: 50, width: 50, decoration: BoxDecoration( borderRadius: BorderRadius.circular(25), color: _actionButtonColor, ), child: Icon(Icons.edit)), ), PaddingSmall(isHorizontal: true), InkWell( onTap: () { generateInviteLink().then((value) { _showInviteDialogue( context: context, message: value); }); }, child: Container( height: 50, width: 100, alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(25), color: _actionButtonColor, ), child: Text( 'Invite ', style: TextStyle( color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold), ), ), ), ], ), ), ], ), ), ), Center( child: Opacity( opacity: shrinkOffset / expandedHeight, child: Text( name, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w700, fontSize: 23, ), ), ), ), Positioned( // top: 60, top: expandedHeight / 1.3 - shrinkOffset, left: constants.padding_large, right: constants.padding_large, child: _buildUserDetailOverlayContainer(), ), ), ), ], ); } [/code] Причина, по которой я использовал SliverpersistentHeader over sliverappbar , потому что я хочу положить наложение карты.> Подробнее здесь: [url]https://stackoverflow.com/questions/64437189/not-able-to-click-on-action-buttons-on-sliverpersistentheader-when-user-scrolls[/url]