Skip to content

Commit

Permalink
* Added sectionFooterBuilder option for adding section footers.
Browse files Browse the repository at this point in the history
  • Loading branch information
meetleev committed Dec 26, 2023
1 parent a2f0b56 commit bfeda1c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.1

* Added sectionFooterBuilder option for adding section footers.

## 0.1.0

* add absorbChildPointer option for toggle mode
Expand Down
29 changes: 25 additions & 4 deletions example/lib/page/grouped_scroll_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ class GroupedScrollViewTestPage extends StatelessWidget {
(BuildContext context, int year, int groupedIndex) =>
Container(
color: Colors.white,
padding: const EdgeInsets.all(8),
alignment: Alignment.centerLeft,
padding: const EdgeInsets.only(left: 8),
constraints: const BoxConstraints.tightFor(height: 30),
child: Text(
'$year',
style: const TextStyle(fontWeight: FontWeight.bold),
),
))
),
sectionFooterBuilder:
(BuildContext cxt, int year, int groupedIndex) =>
_buildSectionFooter(cxt, year, groupedIndex))
: null,
itemBuilder: (BuildContext context, Person item) {
return Container(
Expand Down Expand Up @@ -120,13 +124,17 @@ class GroupedScrollViewTestPage extends StatelessWidget {
(BuildContext context, int year, int groupedIndex) =>
Container(
color: Colors.white,
padding: const EdgeInsets.all(8),
alignment: Alignment.centerLeft,
padding: const EdgeInsets.only(left: 8),
constraints: const BoxConstraints.tightFor(height: 30),
child: Text(
'$year',
style: const TextStyle(fontWeight: FontWeight.bold),
),
))
),
sectionFooterBuilder:
(BuildContext cxt, int year, int groupedIndex) =>
_buildSectionFooter(cxt, year, groupedIndex))
: null,
itemBuilder: (BuildContext context, Person item) {
return Container(
Expand Down Expand Up @@ -175,4 +183,17 @@ class GroupedScrollViewTestPage extends StatelessWidget {
),
);
}

Widget _buildSectionFooter(BuildContext cxt, int year, int groupedIndex) {
return Container(
color: Colors.white,
constraints: const BoxConstraints.tightFor(height: 30),
child: Center(
child: Text(
'SectionFooter - $year',
style: const TextStyle(fontWeight: FontWeight.bold),
),
),
);
}
}
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: example
description: A new Flutter project.
description: grouped scrollview example.

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
Expand All @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.2
version: 1.0.3

environment:
sdk: ">=2.18.0 <4.0.0"
Expand Down Expand Up @@ -47,7 +47,7 @@ dev_dependencies:
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.2
flutter_lints: ^3.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
4 changes: 2 additions & 2 deletions lib/src/grouped_scroll_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class GroupedScrollView<T, H> extends StatelessWidget {
final GroupedScrollViewOptions<T, H>? groupedOptions;

const GroupedScrollView({
Key? key,
super.key,
required this.data,
this.headerBuilder,
this.footerBuilder,
Expand Down Expand Up @@ -147,7 +147,7 @@ class GroupedScrollView<T, H> extends StatelessWidget {
this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
this.restorationId,
this.clipBehavior = Clip.hardEdge,
}) : super(key: key);
});

const GroupedScrollView.grid({
super.key,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/grouped_scroll_view_with_toggle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class GroupedScrollViewWithToggle<T, H> extends StatefulWidget {
final bool toggleEnabled;

const GroupedScrollViewWithToggle({
Key? key,
super.key,
required this.data,
this.headerBuilder,
this.footerBuilder,
Expand Down Expand Up @@ -148,7 +148,7 @@ class GroupedScrollViewWithToggle<T, H> extends StatefulWidget {
this.toggleController,
this.toggleItemSize,
this.toggleEnabled = false,
}) : super(key: key);
});

const GroupedScrollViewWithToggle.grid({
super.key,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: grouped_scroll_view
description: Provide a List, a grouper, and let it display it as a ListView, a GridView or anything else. Supports checkbox or radio in a scrollView.
version: 0.1.0
version: 0.1.1
homepage: https://github.com/meetleev
repository: https://github.com/meetleev/flutter_grouped_scroll_view

Expand Down

0 comments on commit bfeda1c

Please sign in to comment.