Skip to content

Commit 41f9a2d

Browse files
committed
msglist: Fix double-padding of bottom inset
The user-visible effect was pretty small, so I didn't debug it fully in PR #3: on my iPhone, before this commit, scrolling all the way down in the message list left about a centimeter, maybe less, between the bottom of the latest message and the top of the compose-box placeholder. Now, on my iPhone, scrolling down puts the bottom edge of the latest message flush with the top of the compose-box placeholder, as has been the case on devices without insets. I'm not sure if that's quite the effect we want, but if we want to add padding, we should do it on purpose. Addressing Greg's TODO in 88f3b73 would have prevented this bug from sneaking in; I'll take care of that next: // TODO have MessageListPage adjust the MediaQuery so we don't // have to worry about this here
1 parent 88f3b73 commit 41f9a2d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/widgets/message_list.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,24 @@ class _MessageListState extends State<MessageList> {
9393
final length = model!.messages.length;
9494
assert(model!.contents.length == length);
9595
return StickyHeaderListView.builder(
96+
// If the `padding` param is omitted or null, StickyHeaderListView pads
97+
// the content area (the part that moves when you scroll) with
98+
// `MediaQueryData.padding`. It inherits this behavior from
99+
// BoxScrollView:
100+
// https://github.com/flutter/flutter/blob/3.7.0-1.2.pre/packages/flutter/lib/src/widgets/scroll_view.dart#L665-L687
101+
//
102+
// A non-ancestor (the compose box) pads the bottom inset, so the
103+
// ambient `MediaQueryData.padding` might be nonzero. So, prevent double
104+
// padding at the bottom by supplying a `padding` param.
105+
//
106+
// (A non-ancestor, the app bar, pads the top inset, but we don't
107+
// need the remedy of a non-null `padding` for the top because the
108+
// ambient `MediaQueryData.padding` has `top: 0` thanks to Scaffold
109+
// setting that on its `body`, since it knows about the app bar:
110+
// https://github.com/flutter/flutter/blob/3.7.0-1.2.pre/packages/flutter/lib/src/material/scaffold.dart#L2778
111+
// )
112+
padding: const EdgeInsets.all(0),
113+
96114
itemCount: length,
97115
// Setting reverse: true means the scroll starts at the bottom.
98116
// Flipping the indexes (in itemBuilder) means the start/bottom

0 commit comments

Comments
 (0)