Skip to content

Commit d0e2988

Browse files
committed
compose [nfc]: Make just one call to _ComposeBoxContainer
1 parent 6202186 commit d0e2988

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

lib/widgets/compose_box.dart

+24-23
Original file line numberDiff line numberDiff line change
@@ -1291,31 +1291,32 @@ class _ComposeBoxState extends State<ComposeBox> implements ComposeBoxState {
12911291

12921292
@override
12931293
Widget build(BuildContext context) {
1294+
final Widget body;
1295+
12941296
final errorBanner = _errorBanner(context);
12951297
if (errorBanner != null) {
1296-
return _ComposeBoxContainer(child: errorBanner);
1297-
}
1298-
1299-
final narrow = widget.narrow;
1300-
final Widget body;
1301-
switch (narrow) {
1302-
case ChannelNarrow():
1303-
assert(_controller is StreamComposeBoxController);
1304-
body = _StreamComposeBoxBody(controller: (_controller as StreamComposeBoxController),
1305-
narrow: narrow);
1306-
case TopicNarrow():
1307-
assert(_controller is FixedDestinationComposeBoxController);
1308-
body = _FixedDestinationComposeBoxBody(controller: (_controller as FixedDestinationComposeBoxController),
1309-
narrow: narrow);
1310-
case DmNarrow():
1311-
assert(_controller is FixedDestinationComposeBoxController);
1312-
body = _FixedDestinationComposeBoxBody(controller: (_controller as FixedDestinationComposeBoxController),
1313-
narrow: narrow);
1314-
case CombinedFeedNarrow():
1315-
case MentionsNarrow():
1316-
case StarredMessagesNarrow():
1317-
assert(false);
1318-
body = const SizedBox.shrink();
1298+
body = errorBanner;
1299+
} else {
1300+
final narrow = widget.narrow;
1301+
switch (narrow) {
1302+
case ChannelNarrow():
1303+
assert(_controller is StreamComposeBoxController);
1304+
body = _StreamComposeBoxBody(controller: (_controller as StreamComposeBoxController),
1305+
narrow: narrow);
1306+
case TopicNarrow():
1307+
assert(_controller is FixedDestinationComposeBoxController);
1308+
body = _FixedDestinationComposeBoxBody(controller: (_controller as FixedDestinationComposeBoxController),
1309+
narrow: narrow);
1310+
case DmNarrow():
1311+
assert(_controller is FixedDestinationComposeBoxController);
1312+
body = _FixedDestinationComposeBoxBody(controller: (_controller as FixedDestinationComposeBoxController),
1313+
narrow: narrow);
1314+
case CombinedFeedNarrow():
1315+
case MentionsNarrow():
1316+
case StarredMessagesNarrow():
1317+
assert(false);
1318+
body = const SizedBox.shrink();
1319+
}
13191320
}
13201321

13211322
return _ComposeBoxContainer(child: body);

0 commit comments

Comments
 (0)