@@ -590,7 +590,13 @@ class _CodelesslyWidgetState extends State<CodelesslyWidget> {
590590 _label, 'Layout loaded in ${millis }ms or ${millis / 1000 }s' );
591591 }
592592
593- return _effectiveLayoutBuilder (context, layoutWidget);
593+ return _NavigationBuilder (
594+ key: ValueKey (effectiveLayoutID),
595+ layoutId: effectiveLayoutID,
596+ builder: (context) {
597+ return _effectiveLayoutBuilder (context, layoutWidget);
598+ },
599+ );
594600 } catch (e, str) {
595601 print (e);
596602 print (str);
@@ -621,43 +627,37 @@ class _CodelesslyWidgetState extends State<CodelesslyWidget> {
621627 value: codelessly,
622628 ),
623629 ],
624- child: _NavigationBuilder (
625- key: ValueKey (_effectiveController.layoutID),
626- // TODO(Saad): Ensure this is not null on first load in non-simulated cases.
627- layoutId: _effectiveController.layoutID,
628- builder: (context) {
629- return StreamBuilder <CStatus >(
630- stream: codelessly.statusStream,
631- initialData: codelessly.status,
632- builder: (context, snapshot) {
633- Widget loading () =>
634- _effectiveLoadingBuilder? .call (context) ??
635- const CodelesslyLoadingScreen ();
636- Widget error (Object ? exception) {
637- final error = exception ?? snapshot.error;
638- return _effectiveErrorBuilder? .call (context, error) ??
639- CodelesslyErrorScreen (
640- exception: error,
641- publishSource: _effectiveController.publishSource,
642- );
643- }
644-
645- if (snapshot.hasError) return error (snapshot.error);
646- if (! snapshot.hasData) return loading ();
647-
648- final CStatus status = snapshot.data! ;
649- return switch (status) {
650- CEmpty () || CConfigured () => loading (),
651- CError () => error (status.exception),
652- CLoading (state: CLoadingState state) =>
653- state.hasPassed (CLoadingState .createdManagers)
654- ? buildStreamedLayout ()
655- : loading (),
656- CLoaded () => buildStreamedLayout (),
657- };
658- },
659- );
660- }),
630+ child: StreamBuilder <CStatus >(
631+ stream: codelessly.statusStream,
632+ initialData: codelessly.status,
633+ builder: (context, snapshot) {
634+ Widget loading () =>
635+ _effectiveLoadingBuilder? .call (context) ??
636+ const CodelesslyLoadingScreen ();
637+ Widget error (Object ? exception) {
638+ final error = exception ?? snapshot.error;
639+ return _effectiveErrorBuilder? .call (context, error) ??
640+ CodelesslyErrorScreen (
641+ exception: error,
642+ publishSource: _effectiveController.publishSource,
643+ );
644+ }
645+
646+ if (snapshot.hasError) return error (snapshot.error);
647+ if (! snapshot.hasData) return loading ();
648+
649+ final CStatus status = snapshot.data! ;
650+ return switch (status) {
651+ CEmpty () || CConfigured () => loading (),
652+ CError () => error (status.exception),
653+ CLoading (state: CLoadingState state) =>
654+ state.hasPassed (CLoadingState .createdManagers)
655+ ? buildStreamedLayout ()
656+ : loading (),
657+ CLoaded () => buildStreamedLayout (),
658+ };
659+ },
660+ ),
661661 );
662662 }
663663}
0 commit comments