@@ -295,7 +295,7 @@ class _MessageListPageState extends State<MessageListPage> implements MessageLis
295295 }
296296
297297 Widget result = Scaffold (
298- appBar: _MessageListAppBar . build (context, narrow: narrow),
298+ appBar: _MessageListAppBar ( narrow: narrow),
299299 // TODO question for Vlad: for a stream view, should we set the Scaffold's
300300 // [backgroundColor] based on stream color, as in this frame:
301301 // https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=132%3A9684&mode=dev
@@ -370,18 +370,18 @@ class _RevealedMutedMessagesProvider extends InheritedNotifier<RevealedMutedMess
370370 RevealedMutedMessagesState get state => notifier! ;
371371}
372372
373- // Conceptually this should be a widget class. But it needs to be a
374- // PreferredSizeWidget, with the `preferredSize` that the underlying AppBar
375- // will have... and there's currently no good way to get that value short of
376- // constructing the whole AppBar widget with all its properties.
377- // So this has to be built eagerly by its parent's build method,
378- // making it a build function rather than a widget. Discussion:
379- // https://github.com/zulip/zulip-flutter/pull/1662#discussion_r2183471883
380- // Still we can organize it on a class, with the name the widget would have.
381- // TODO(upstream): AppBar should expose a bit more API so that it's possible
382- // to customize by composition in a reasonable way.
383- abstract class _MessageListAppBar {
384- static AppBar build (BuildContext context, { required Narrow narrow} ) {
373+ class _MessageListAppBar extends StatelessWidget implements PreferredSizeWidget {
374+ _MessageListAppBar ({ required this .narrow});
375+
376+ final Narrow narrow;
377+
378+ @override
379+ final Size preferredSize = preferredSizeFor ();
380+
381+ static Size preferredSizeFor () => ZulipAppBar . preferredSizeFor ();
382+
383+ @override
384+ Widget build (BuildContext context) {
385385 final store = PerAccountStoreWidget .of (context);
386386 final messageListTheme = MessageListTheme .of (context);
387387 final zulipLocalizations = ZulipLocalizations .of (context);
0 commit comments