Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions example/lib/chat_example.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -97,7 +96,7 @@ List<Message> get getOlderMessages => [
];

class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
State<MyApp> createState() => _MyAppState();
Expand Down Expand Up @@ -268,7 +267,7 @@ class _ChatTimelineState extends State<ChatTimeline> {
}

class FakeMessageTextField extends StatelessWidget {
const FakeMessageTextField({Key? key}) : super(key: key);
const FakeMessageTextField({super.key});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -302,12 +301,12 @@ class FakeMessageTextField extends StatelessWidget {
maxLines: 8,
decoration: InputDecoration(
prefixIcon: IconButton(
onPressed: () => null,
onPressed: () {},
icon: Icon(Icons.camera_alt_outlined,
color: Theme.of(context).primaryColor),
),
suffixIcon: IconButton(
onPressed: () => null,
onPressed: () {},
icon: Icon(Icons.send, color: Theme.of(context).primaryColor),
),
),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ List _elements = [
];

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -48,7 +48,7 @@ class MyApp extends StatelessWidget {
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
),
itemBuilder: (c, element) {
itemBuilder: (c, element, prevElement) {
return Card(
elevation: 8.0,
margin: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/section_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ List _elements = [
];

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -48,7 +48,7 @@ class MyApp extends StatelessWidget {
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
),
itemBuilder: (c, element) {
itemBuilder: (c, element, prevElement) {
return Card(
elevation: 8.0,
margin: const EdgeInsets.symmetric(horizontal: 10.0),
Expand Down
2 changes: 1 addition & 1 deletion example/lib/silver_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ List _elements = [
];

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context) {
Expand Down
4 changes: 2 additions & 2 deletions example/lib/stream_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ List<Element> _elements = [];
int counter = 1;

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -57,7 +57,7 @@ class MyApp extends StatelessWidget {
order: GroupedListOrder.DESC,
useStickyGroupSeparators: true,
groupSeparatorBuilder: (int groupValue) => _createGroupHeader(groupValue),
itemBuilder: (ctx, element) => _createItem(element.name),
itemBuilder: (ctx, element, prevElement) => _createItem(element.name),
);
}

Expand Down
10 changes: 8 additions & 2 deletions lib/grouped_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class GroupedListView<T, E> extends StatefulWidget {

/// Called to build children for the list with
/// 0 <= element < elements.length.
final Widget Function(BuildContext context, T element)? itemBuilder;
final Widget Function(BuildContext context, T element, T? prevElement)?
itemBuilder;

/// Called to build the children for the list where the current element
/// depends of the previous and next elements
Expand Down Expand Up @@ -290,7 +291,11 @@ class _GroupedListViewState<T, E> extends State<GroupedListView<T, E>> {
void initState() {
_controller = widget.controller ?? ScrollController();
if (widget.useStickyGroupSeparators) {
_controller.addListener(_scrollListener);
_controller.addListener(() {
WidgetsBinding.instance.addPostFrameCallback((_) {
_scrollListener();
});
});
}
super.initState();
}
Expand Down Expand Up @@ -425,6 +430,7 @@ class _GroupedListViewState<T, E> extends State<GroupedListView<T, E>> {
: widget.itemBuilder!(
context,
_sortedElements[index],
index > 0 ? _sortedElements[index - 1] : null,
),
);

Expand Down
2 changes: 1 addition & 1 deletion test/grouped_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void main() {
order: GroupedListOrder.ASC,
groupSeparatorBuilder: (dynamic element) =>
SizedBox(height: 50, child: Text('$element')),
itemBuilder: (_, dynamic element) => SizedBox(
itemBuilder: (_, dynamic element, dynamic prevElement) => SizedBox(
height: 100,
child: Text(element['name']),
),
Expand Down