@@ -212,41 +212,48 @@ class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver {
212
212
213
213
@override
214
214
Widget build (BuildContext context) {
215
- final themeData = zulipThemeData (context);
216
215
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
+ // TODO: any way to remove the [Builder], like how we pulled out
227
+ // [_handleGenerateInitialRoutes]?
228
+ theme: zulipThemeData (context),
229
+
230
+ navigatorKey: ZulipApp .navigatorKey,
231
+ navigatorObservers: [
232
+ if (widget.navigatorObservers != null )
233
+ ...widget.navigatorObservers! ,
234
+ _PreventEmptyStack (),
235
+ ],
236
+ builder: (BuildContext context, Widget ? child) {
237
+ if (! ZulipApp .ready.value) {
238
+ SchedulerBinding .instance.addPostFrameCallback (
239
+ (_) => widget._declareReady ());
240
+ }
241
+ GlobalLocalizations .zulipLocalizations = ZulipLocalizations .of (context);
242
+ return child! ;
243
+ },
244
+
245
+ // We use onGenerateInitialRoutes for the real work of specifying the
246
+ // initial nav state. To do that we need [MaterialApp] to decide to
247
+ // build a [Navigator]... which means specifying either `home`, `routes`,
248
+ // `onGenerateRoute`, or `onUnknownRoute`. Make it `onGenerateRoute`.
249
+ // It never actually gets called, though: `onGenerateInitialRoutes`
250
+ // handles startup, and then we always push whole routes with methods
251
+ // like [Navigator.push], never mere names as with [Navigator.pushNamed].
252
+ onGenerateRoute: (_) => null ,
253
+
254
+ onGenerateInitialRoutes: _handleGenerateInitialRoutes);
255
+ }
256
+ ));
250
257
}
251
258
}
252
259
0 commit comments