Revert "fix(ui): fix MessageListView header and footer while reverse: false"

This reverts commit 59ded0e033.
This commit is contained in:
Salvatore Giordano
2021-09-20 15:54:50 +02:00
parent 59ded0e033
commit 8cb95cfd7c
@@ -494,18 +494,14 @@ class _MessageListViewState extends State<MessageListView> {
return _buildThreadSeparator(); return _buildThreadSeparator();
} }
if (i == itemCount - 3) { if (i == itemCount - 3) {
if (widget.reverse if (widget.headerBuilder == null) {
? widget.headerBuilder == null
: widget.footerBuilder == null) {
if (_isThreadConversation) return const Offstage(); if (_isThreadConversation) return const Offstage();
return const SizedBox(height: 52); return const SizedBox(height: 52);
} }
return const SizedBox(height: 8); return const SizedBox(height: 8);
} }
if (i == 0) { if (i == 0) {
if (widget.reverse if (widget.footerBuilder == null) {
? widget.footerBuilder == null
: widget.headerBuilder == null) {
return const SizedBox(height: 30); return const SizedBox(height: 30);
} }
return const SizedBox(height: 8); return const SizedBox(height: 8);
@@ -564,13 +560,8 @@ class _MessageListViewState extends State<MessageListView> {
} }
if (i == itemCount - 2) { if (i == itemCount - 2) {
if (widget.reverse) { return widget.headerBuilder?.call(context) ??
return widget.headerBuilder?.call(context) ?? const Offstage();
const Offstage();
} else {
return widget.footerBuilder?.call(context) ??
const Offstage();
}
} }
if (i == itemCount - 3) { if (i == itemCount - 3) {
@@ -588,13 +579,8 @@ class _MessageListViewState extends State<MessageListView> {
} }
if (i == 0) { if (i == 0) {
if (widget.reverse) { return widget.footerBuilder?.call(context) ??
return widget.footerBuilder?.call(context) ?? const Offstage();
const Offstage();
} else {
return widget.headerBuilder?.call(context) ??
const Offstage();
}
} }
const bottomMessageIndex = 2; // 1 -> loader // 0 -> footer const bottomMessageIndex = 2; // 1 -> loader // 0 -> footer
@@ -1213,10 +1199,12 @@ class _MessageListViewState extends State<MessageListView> {
initialAlignment = _initialAlignment; initialAlignment = _initialAlignment;
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) { WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
_scrollController?.jumpTo( if (_scrollController?.isAttached == true) {
index: initialIndex, _scrollController?.jumpTo(
alignment: initialAlignment, index: initialIndex,
); alignment: initialAlignment,
);
}
}); });
_messageNewListener = _messageNewListener =