Skip to content

Commit d6e2f5b

Browse files
committed
Simulator #14
1 parent e08a516 commit d6e2f5b

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

lib/src/functions/functions_repository.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class FunctionsRepository {
243243
_log('Performing navigation action with params: $parsedParams');
244244

245245
final Codelessly codelessly = context.read<Codelessly>();
246-
final String myLayoutId = codelessly.currentNavigatedLayoutId!;
246+
final String? myLayoutId = codelessly.currentNavigatedLayoutId;
247247

248248
if (action.navigationType == NavigationType.pop) {
249249
await Navigator.maybePop(context, parsedParams);
@@ -328,7 +328,7 @@ class FunctionsRepository {
328328
_log('Performing show dialog action with params: $parsedParams');
329329

330330
final Codelessly codelessly = context.read<Codelessly>();
331-
final myLayoutId = codelessly.currentNavigatedLayoutId!;
331+
final String? myLayoutId = codelessly.currentNavigatedLayoutId;
332332

333333
// Check if a layout exists for the action's [destinationId].
334334
final String? layoutId = codelessly.dataManager.publishModel?.layouts.values

lib/src/ui/codelessly_widget.dart

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)