Skip to content

msglist: Simplify safe-area handling; fix a small bug #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 17, 2023
Merged
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
25 changes: 18 additions & 7 deletions lib/widgets/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,23 @@ class MessageListPage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("All messages")),
body: Center(
child: Column(children: const [
Expanded(child: MessageList()),
SizedBox(
height: 80,
child: Center(child: Text("(Compose box goes here.)"))),
])));
body: Builder(
builder: (BuildContext context) => Center(
child: Column(children: [
MediaQuery.removePadding(
// Scaffold knows about the app bar, and so has run this
// BuildContext, which is under `body`, through
// MediaQuery.removePadding with `removeTop: true`.
context: context,

// The compose box pads the bottom inset.
removeBottom: true,

child: const Expanded(
child: MessageList())),
const SizedBox(
height: 80,
child: Center(
child: Text("(Compose box goes here.)")))]))));
}
}
12 changes: 0 additions & 12 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,6 @@ class _MessageListState extends State<MessageList> {

// Pad the left and right insets, for small devices in landscape.
child: SafeArea(
// A non-ancestor (the compose box) pads the bottom inset;
// prevent extra padding here.
// TODO have MessageListPage adjust the MediaQuery so we don't
// have to worry about this here
bottom: false,

// A non-ancestor (the app bar) pads the top inset. But no
// need to prevent extra padding with `top: false`, because
// Scaffold, which knows about the app bar, sets `body`'s
// ambient `MediaQueryData.padding` to have `top: 0`:
// https://github.com/flutter/flutter/blob/3.7.0-1.2.pre/packages/flutter/lib/src/material/scaffold.dart#L2778

// Keep some padding when there are no horizontal insets,
// which is usual in portrait mode.
minimum: const EdgeInsets.symmetric(horizontal: 8),
Expand Down