cachingPageLoaderFor method
Page loader that serves cache entries from memory and falls back to the
live client for any other uri.
The server-open path already reads the entry page (ui://app) once to
detect its type before promoting it to an application (wrapAsApplication).
Routing that page through the client again — a second read over a possibly
dead link — is what surfaced "Failed to load page / Client is not
initialized" on a screen with no way out. Feeding the already-parsed
content back through the cache means the app's first frame renders from
memory, so its AppBar (and its close/exit affordance) is always present,
even if the connection dropped right after the initial load.
Implementation
PageLoader cachingPageLoaderFor(
Client client,
Map<String, Map<String, dynamic>> cache, {
Map<String, dynamic> Function(Map<String, dynamic>)? transform,
}) =>
cachingResolvingPageLoader(() async => client, cache, transform: transform);