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