@@ -26,12 +26,12 @@ import 'text.dart';
26
26
import 'theme.dart' ;
27
27
28
28
class MessageListPage extends StatefulWidget {
29
- const MessageListPage ({super .key, required this .narrow });
29
+ const MessageListPage ({super .key, required this .initNarrow });
30
30
31
31
static Route <void > buildRoute ({int ? accountId, BuildContext ? context,
32
32
required Narrow narrow}) {
33
33
return MaterialAccountWidgetRoute (accountId: accountId, context: context,
34
- page: MessageListPage (narrow : narrow));
34
+ page: MessageListPage (initNarrow : narrow));
35
35
}
36
36
37
37
/// A [ComposeBoxController] , if this [MessageListPage] offers a compose box.
@@ -44,7 +44,7 @@ class MessageListPage extends StatefulWidget {
44
44
return messageListPageState! ._composeBoxKey.currentState;
45
45
}
46
46
47
- final Narrow narrow ;
47
+ final Narrow initNarrow ;
48
48
49
49
@override
50
50
State <MessageListPage > createState () => _MessageListPageState ();
@@ -54,15 +54,22 @@ class MessageListPage extends StatefulWidget {
54
54
const _kUnsubscribedStreamRecipientHeaderColor = Color (0xfff5f5f5 );
55
55
56
56
class _MessageListPageState extends State <MessageListPage > {
57
+ Narrow ? narrow;
57
58
final GlobalKey <ComposeBoxController > _composeBoxKey = GlobalKey ();
58
59
60
+ @override
61
+ void initState () {
62
+ narrow = widget.initNarrow;
63
+ super .initState ();
64
+ }
65
+
59
66
@override
60
67
Widget build (BuildContext context) {
61
68
final store = PerAccountStoreWidget .of (context);
62
69
63
70
final Color ? appBarBackgroundColor;
64
71
bool removeAppBarBottomBorder = false ;
65
- switch (widget. narrow) {
72
+ switch (narrow! ) {
66
73
case CombinedFeedNarrow ():
67
74
appBarBackgroundColor = null ; // i.e., inherit
68
75
@@ -84,7 +91,7 @@ class _MessageListPageState extends State<MessageListPage> {
84
91
}
85
92
86
93
return Scaffold (
87
- appBar: AppBar (title: MessageListAppBarTitle (narrow: widget. narrow),
94
+ appBar: AppBar (title: MessageListAppBarTitle (narrow: narrow! ),
88
95
backgroundColor: appBarBackgroundColor,
89
96
shape: removeAppBarBottomBorder
90
97
? const Border ()
@@ -110,11 +117,11 @@ class _MessageListPageState extends State<MessageListPage> {
110
117
// if those details get complicated, refactor to avoid copying.
111
118
// TODO(#311) If we have a bottom nav, it will pad the bottom
112
119
// inset, and this should always be true.
113
- removeBottom: widget. narrow is ! CombinedFeedNarrow ,
120
+ removeBottom: narrow is ! CombinedFeedNarrow ,
114
121
115
122
child: Expanded (
116
- child: MessageList (narrow: widget. narrow))),
117
- ComposeBox (controllerKey: _composeBoxKey, narrow: widget. narrow),
123
+ child: MessageList (narrow: narrow! ))),
124
+ ComposeBox (controllerKey: _composeBoxKey, narrow: narrow! ),
118
125
]))));
119
126
}
120
127
}
0 commit comments