@@ -20,7 +20,7 @@ class OverwriteSelectionSheet<T> extends ConsumerWidget {
2020 final String title;
2121 final List <OverwriteSelectionSection <T >> sections;
2222 final String Function (T item) labelBuilder;
23- final bool Function (WidgetRef ref, T item) isSelectedOf ;
23+ final T ? Function (WidgetRef ref) selectedOf ;
2424 final ValueChanged <T > onSelected;
2525 final double ? bottomHeightFactor;
2626 final String ? emptyLabel;
@@ -30,21 +30,20 @@ class OverwriteSelectionSheet<T> extends ConsumerWidget {
3030 required this .title,
3131 required this .sections,
3232 required this .labelBuilder,
33- required this .isSelectedOf ,
33+ required this .selectedOf ,
3434 required this .onSelected,
3535 this .bottomHeightFactor = 0.70 ,
3636 this .emptyLabel,
3737 });
3838
3939 Widget _buildItem (
4040 BuildContext context,
41- WidgetRef ref,
4241 OverwriteSelectionSection <T > section,
4342 T item,
4443 int index,
44+ bool isSelected,
4545 ) {
4646 final position = ItemPosition .get (index, section.items.length);
47- final isSelected = isSelectedOf (ref, item);
4847 return ItemPositionProvider (
4948 position: position,
5049 child: DecorationListItem (
@@ -69,31 +68,46 @@ class OverwriteSelectionSheet<T> extends ConsumerWidget {
6968 Widget build (BuildContext context, ref) {
7069 final height = ref.sheetHeight (context, (bottomHeightFactor ?? 1 ));
7170 final isEmpty = sections.every ((section) => section.items.isEmpty);
71+ final selected = selectedOf (ref);
7272 return AdaptiveSheetScaffold (
7373 sheetTransparentToolBar: true ,
7474 body: SizedBox (
7575 height: height,
7676 child: isEmpty && emptyLabel != null
7777 ? NullStatus (label: emptyLabel! )
78- : ListView (
79- padding : const EdgeInsets . symmetric (
80- horizontal : 16 ,
81- ). copyWith (bottom : 20 , top : context.sheetTopPadding),
82- children : [
78+ : CustomScrollView (
79+ slivers : [
80+ SliverToBoxAdapter (
81+ child : SizedBox (height : context.sheetTopPadding),
82+ ),
8383 for (final section in sections) ...[
8484 if (section.label != null ) ...[
85- InfoHeader (info: Info (label: section.label! )),
86- const SizedBox (height: 4 ),
85+ SliverPadding (
86+ padding: const EdgeInsets .symmetric (horizontal: 16 ),
87+ sliver: SliverToBoxAdapter (
88+ child: InfoHeader (info: Info (label: section.label! )),
89+ ),
90+ ),
91+ const SliverToBoxAdapter (child: SizedBox (height: 4 )),
8792 ],
88- for (var index = 0 ; index < section.items.length; index++ )
89- _buildItem (
90- context,
91- ref,
92- section,
93- section.items[index],
94- index,
93+ SliverPadding (
94+ padding: const EdgeInsets .symmetric (horizontal: 16 ),
95+ sliver: SliverList .builder (
96+ itemCount: section.items.length,
97+ itemBuilder: (context, index) {
98+ final item = section.items[index];
99+ return _buildItem (
100+ context,
101+ section,
102+ item,
103+ index,
104+ item == selected,
105+ );
106+ },
95107 ),
108+ ),
96109 ],
110+ const SliverToBoxAdapter (child: SizedBox (height: 20 )),
97111 ],
98112 ),
99113 ),
0 commit comments