@@ -191,12 +191,12 @@ abstract class MessageListPageState {
191
191
}
192
192
193
193
class MessageListPage extends StatefulWidget {
194
- const MessageListPage ({super .key, required this .narrow });
194
+ const MessageListPage ({super .key, required this .initNarrow });
195
195
196
196
static Route <void > buildRoute ({int ? accountId, BuildContext ? context,
197
197
required Narrow narrow}) {
198
198
return MaterialAccountWidgetRoute (accountId: accountId, context: context,
199
- page: MessageListPage (narrow : narrow));
199
+ page: MessageListPage (initNarrow : narrow));
200
200
}
201
201
202
202
/// The [MessageListPageState] above this context in the tree.
@@ -211,29 +211,35 @@ class MessageListPage extends StatefulWidget {
211
211
return state! ;
212
212
}
213
213
214
- final Narrow narrow ;
214
+ final Narrow initNarrow ;
215
215
216
216
@override
217
217
State <MessageListPage > createState () => _MessageListPageState ();
218
218
}
219
219
220
220
class _MessageListPageState extends State <MessageListPage > implements MessageListPageState {
221
221
@override
222
- Narrow get narrow => widget. narrow;
222
+ late Narrow narrow;
223
223
224
224
@override
225
225
ComposeBoxController ? get composeBoxController => _composeBoxKey.currentState;
226
226
227
227
final GlobalKey <ComposeBoxController > _composeBoxKey = GlobalKey ();
228
228
229
+ @override
230
+ void initState () {
231
+ super .initState ();
232
+ narrow = widget.initNarrow;
233
+ }
234
+
229
235
@override
230
236
Widget build (BuildContext context) {
231
237
final store = PerAccountStoreWidget .of (context);
232
238
final messageListTheme = MessageListTheme .of (context);
233
239
234
240
final Color ? appBarBackgroundColor;
235
241
bool removeAppBarBottomBorder = false ;
236
- switch (widget. narrow) {
242
+ switch (narrow) {
237
243
case CombinedFeedNarrow ():
238
244
case MentionsNarrow ():
239
245
appBarBackgroundColor = null ; // i.e., inherit
@@ -256,7 +262,7 @@ class _MessageListPageState extends State<MessageListPage> implements MessageLis
256
262
}
257
263
258
264
return Scaffold (
259
- appBar: AppBar (title: MessageListAppBarTitle (narrow: widget. narrow),
265
+ appBar: AppBar (title: MessageListAppBarTitle (narrow: narrow),
260
266
backgroundColor: appBarBackgroundColor,
261
267
shape: removeAppBarBottomBorder
262
268
? const Border ()
@@ -280,11 +286,11 @@ class _MessageListPageState extends State<MessageListPage> implements MessageLis
280
286
// The compose box, when present, pads the bottom inset.
281
287
// TODO(#311) If we have a bottom nav, it will pad the bottom
282
288
// inset, and this should always be true.
283
- removeBottom: ComposeBox .hasComposeBox (widget. narrow),
289
+ removeBottom: ComposeBox .hasComposeBox (narrow),
284
290
285
291
child: Expanded (
286
- child: MessageList (narrow: widget. narrow))),
287
- ComposeBox (controllerKey: _composeBoxKey, narrow: widget. narrow),
292
+ child: MessageList (narrow: narrow))),
293
+ ComposeBox (controllerKey: _composeBoxKey, narrow: narrow),
288
294
]))));
289
295
}
290
296
}
0 commit comments