@@ -212,41 +212,44 @@ class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver {
212212
213213 @override
214214 Widget build (BuildContext context) {
215- final themeData = zulipThemeData (context);
216215 return GlobalStoreWidget (
217- child: MaterialApp (
218- onGenerateTitle: (BuildContext context) {
219- return ZulipLocalizations .of (context).zulipAppTitle;
220- },
221- localizationsDelegates: ZulipLocalizations .localizationsDelegates,
222- supportedLocales: ZulipLocalizations .supportedLocales,
223- theme: themeData,
224-
225- navigatorKey: ZulipApp .navigatorKey,
226- navigatorObservers: [
227- if (widget.navigatorObservers != null )
228- ...widget.navigatorObservers! ,
229- _PreventEmptyStack (),
230- ],
231- builder: (BuildContext context, Widget ? child) {
232- if (! ZulipApp .ready.value) {
233- SchedulerBinding .instance.addPostFrameCallback (
234- (_) => widget._declareReady ());
235- }
236- GlobalLocalizations .zulipLocalizations = ZulipLocalizations .of (context);
237- return child! ;
238- },
239-
240- // We use onGenerateInitialRoutes for the real work of specifying the
241- // initial nav state. To do that we need [MaterialApp] to decide to
242- // build a [Navigator]... which means specifying either `home`, `routes`,
243- // `onGenerateRoute`, or `onUnknownRoute`. Make it `onGenerateRoute`.
244- // It never actually gets called, though: `onGenerateInitialRoutes`
245- // handles startup, and then we always push whole routes with methods
246- // like [Navigator.push], never mere names as with [Navigator.pushNamed].
247- onGenerateRoute: (_) => null ,
248-
249- onGenerateInitialRoutes: _handleGenerateInitialRoutes));
216+ child: Builder (builder: (context) {
217+ return MaterialApp (
218+ onGenerateTitle: (BuildContext context) {
219+ return ZulipLocalizations .of (context).zulipAppTitle;
220+ },
221+ localizationsDelegates: ZulipLocalizations .localizationsDelegates,
222+ supportedLocales: ZulipLocalizations .supportedLocales,
223+ // The context has to be taken from the [Builder] because
224+ // [zulipThemeData] requires access to [GlobalStoreWidget] in the tree.
225+ theme: zulipThemeData (context),
226+
227+ navigatorKey: ZulipApp .navigatorKey,
228+ navigatorObservers: [
229+ if (widget.navigatorObservers != null )
230+ ...widget.navigatorObservers! ,
231+ _PreventEmptyStack (),
232+ ],
233+ builder: (BuildContext context, Widget ? child) {
234+ if (! ZulipApp .ready.value) {
235+ SchedulerBinding .instance.addPostFrameCallback (
236+ (_) => widget._declareReady ());
237+ }
238+ GlobalLocalizations .zulipLocalizations = ZulipLocalizations .of (context);
239+ return child! ;
240+ },
241+
242+ // We use onGenerateInitialRoutes for the real work of specifying the
243+ // initial nav state. To do that we need [MaterialApp] to decide to
244+ // build a [Navigator]... which means specifying either `home`, `routes`,
245+ // `onGenerateRoute`, or `onUnknownRoute`. Make it `onGenerateRoute`.
246+ // It never actually gets called, though: `onGenerateInitialRoutes`
247+ // handles startup, and then we always push whole routes with methods
248+ // like [Navigator.push], never mere names as with [Navigator.pushNamed].
249+ onGenerateRoute: (_) => null ,
250+
251+ onGenerateInitialRoutes: _handleGenerateInitialRoutes);
252+ }));
250253 }
251254}
252255
0 commit comments