Skip to content

Instantly share code, notes, and snippets.

@ologunB
Created January 28, 2023 09:20
Show Gist options
  • Save ologunB/9e9acbb0f8bab29f02a1567ec8b681ba to your computer and use it in GitHub Desktop.
Save ologunB/9e9acbb0f8bab29f02a1567ec8b681ba to your computer and use it in GitHub Desktop.
GroupedListView<NewMessageModel, String>(
elements: allMessages,
reverse: true,
controller: _scrollController,
groupBy: (element) =>
(element.createdAt ~/ 86400000).toString(),
groupSeparatorBuilder: (String groupByValue) => Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: 40.h, vertical: 10.h),
decoration: BoxDecoration(
color: AppColors.black,
borderRadius: BorderRadius.circular(8)),
child: regularText(
DateFormat('MMMM dd, yyyy').format(
DateTime.fromMillisecondsSinceEpoch(
int.parse(groupByValue) * 86400000)),
fontSize: 14,
color: AppColors.white,
),
)
],
),
itemBuilder: (context, dynamic element) =>
MessageBubble(
text: element.text,
isSender: element.from == AppCache.getUser.uid,
isRead: element.isRead,
timeSent: DateFormat('hh:mm a').format(
DateTime.fromMillisecondsSinceEpoch(
element.createdAt)),
),
itemComparator: (a,b) =>
a.createdAt.compareTo(b.createdAt),
useStickyGroupSeparators: true,
floatingHeader: true,
order: GroupedListOrder.DESC,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment