v5.0.1sliver_sticky_collapsable_panel
一个粘性可折叠面板的 Sliver 实现,带有状态变化时重新构建的盒子标题和作为面板内容的 Sliver 子项。
117喜欢 3100近 30 天下载160Pub 分数
AndroidiOSWebmacOSWindowsLinux
一个带有粘性可折叠标题和子 Sliver 的面板的 Sliver 实现。
{"sdk":"flutter"}{"sdk":"flutter"}^6.0.0以下为英文项目原文快照,最新内容请访问 GitHub。
pub license build status flutter compatibility dart compatibility
A Sliver implementation of sticky collapsable panel, with a box header rebuild on status and a sliver child as panel content.
sticky: false parameter).disableCollapsable = true parameter in panelController).iOSStyleSticky = true parameter).paddingBeforeCollapse parameter).paddingAfterCollapse parameter).In the pubspec.yaml of your flutter project, add the following dependency:
dependencies:
sliver_sticky_collapsable_panel: ^5.0.1
In your library add the following import:
import 'package:sliver_sticky_collapsable_panel/sliver_sticky_collapsable_panel.dart';
In your code, use the sliver like this:
CustomScrollView(
controller: _scrollController,
slivers: [
SliverStickyCollapsablePanel(
scrollController: _scrollController,
panelController: StickyCollapsablePanelController(key:'key_1'),
headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
sliverPanel: SliverList.list(children: [...]),
),
SliverStickyCollapsablePanel(
scrollController: _scrollController,
panelController: StickyCollapsablePanelController(key:'key_2'),
headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
sliverPanel: SliverList.list(children: [...]),
),
...,
],
);
For simple right side header arrow hint ^, you can build with widget in flutter framework like AnimatedRotation:
SliverStickyCollapsablePanel(
scrollController: _scrollController,
panelController: StickyCollapsablePanelController(key:'key_1'),
headerBuilder: (context, status) => Container(
width: double.infinity,
height: 48,
child: Stack(
children: [
Text("your title, or any other box widget you like"),
Align(
alignment: Alignment.centerRight,
child: AnimatedRotation(
duration: const Duration(milliseconds: 0),
turns: status.isExpanded ? 0 : 0.5,
child: const Icon(Icons.expand_more),
),
),
],
),
),
sliverPanel: SliverList.list(children: [...]),
),
disableCollapsable = true.CustomScrollView(
controller: _scrollController,
slivers: [
SliverStickyCollapsablePanel(
scrollController: _scrollController,
panelController: StickyCollapsablePanelController(key:'key_1',disableCollapsable: true),
headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
sliverPanel: SliverList.list(children: [...]),
),
...,
],
);
iOSStyleSticky = true.CustomScrollView(
controller: _scrollController,
slivers: [
SliverStickyCollapsablePanel(
scrollController: _scrollController,
panelController: StickyCollapsablePanelController(key:'key_1'),
iOSStyleSticky: true,
headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
sliverPanel: SliverList.list(children: [...]),
),
...,
],
);
simple Shot
paddingBeforeCollapse), even if the panel is collapsed, the padding still work between headers with paddingAfterCollapse.CustomScrollView(
controller: _scrollController,
slivers: [
SliverStickyCollapsablePanel(
scrollController: _scrollController,
panelController: StickyCollapsablePanelController(key:'key_1'),
paddingBeforeCollapse: const EdgeInsets.all(16),
paddingAfterCollapse: const EdgeInsets.only(bottom: 10),
headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
sliverPanel: SliverList.list(children: [...]),
),
...,
],
);
simple Shot
panelAnimationDurationCustomScrollView(
controller: _scrollController,
slivers: [
SliverStickyCollapsablePanel(
scrollController: _scrollController,
panelController: StickyCollapsablePanelController(key:'key_1'),
panelAnimationDuration: Duration(milliseconds: 300),
paddingBeforeCollapse: const EdgeInsets.all(16),
paddingAfterCollapse: const EdgeInsets.only(bottom: 10),
headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
sliverPanel: SliverList.list(children: [...]),
),
...,
],
);
headerSize to speed up the layout process when the size not change
CustomScrollView(
controller: _scrollController,
slivers: [
SliverStickyCollapsablePanel(
scrollController: _scrollController,
panelController: StickyCollapsablePanelController(key:'key_1'),
iOSStyleSticky: true,
headerBuilder: (context, status) => SizedBox.fromSize(size: Size.fromHeight(48)),
headerSize: Size(MediaQuery.of(context).size.width, 48),
sliverPanel: SliverList.list(children: [...]),
),
...,
],
);