Skip to content

Commit 57294ea

Browse files
committed
widgets/app [nfc]: Smoothen a wrinkle about MediaQuery.removePadding
1 parent 7b649d6 commit 57294ea

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

lib/widgets/app.dart

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -149,25 +149,23 @@ class MessageListPage extends StatelessWidget {
149149
Widget build(BuildContext context) {
150150
return Scaffold(
151151
appBar: AppBar(title: const Text("All messages")),
152-
body: Center(
153-
child: Column(children: [
154-
MediaQuery.removePadding(
155-
context: context,
156-
157-
// The app bar pads the top inset. (If `context` were for a
158-
// location under Scaffold's `body`, we wouldn't have to
159-
// `removeTop`. Scaffold, which knows about the app bar,
160-
// already applies `removeTop` on `body`:
161-
// https://github.com/flutter/flutter/blob/3.7.0-1.2.pre/packages/flutter/lib/src/material/scaffold.dart#L2778
162-
// )
163-
removeTop: true,
164-
165-
// The compose box pads the bottom inset.
166-
removeBottom: true,
167-
168-
child: const Expanded(child: MessageList())),
169-
const SizedBox(
170-
height: 80,
171-
child: Center(child: Text("(Compose box goes here.)")))])));
152+
body: Builder(
153+
builder: (BuildContext context) => Center(
154+
child: Column(children: [
155+
MediaQuery.removePadding(
156+
// Scaffold knows about the app bar, and so has run this
157+
// BuildContext, which is under `body`, through
158+
// MediaQuery.removePadding with `removeTop: true`.
159+
context: context,
160+
161+
// The compose box pads the bottom inset.
162+
removeBottom: true,
163+
164+
child: const Expanded(
165+
child: MessageList())),
166+
const SizedBox(
167+
height: 80,
168+
child: Center(
169+
child: Text("(Compose box goes here.)")))]))));
172170
}
173171
}

0 commit comments

Comments
 (0)