dartway_serverpod_core_flutter 0.9.0
dartway_serverpod_core_flutter: ^0.9.0 copied to clipboard
Flutter side of the DartWay core: a typed realtime data layer over the Serverpod module, session management, connection-aware error handling and context-rich alerting.
dartway_serverpod_core_flutter #
The Flutter side of the DartWay core: a typed realtime data layer over the DartWay Serverpod module, plus sessions and context-rich error alerting.
- Data layer in one line —
ref.watchModelList<NewsPost>()gives a typed live list: realtime sync, pagination, filters and skeleton loading states out of the box.ref.watchModel/ref.readModelread a single one; writes go throughDwRepository.saveModel/DwRepository.deleteModel— no service wrappers, no manual sockets. - Sessions — passwordless auth flow on the app's own user model, session survives restarts via the authentication key manager.
- Out-of-the-box alerting — errors are reported with app context
(current route, mounted features, failed action or
endpoint.method, platform, app version, user) instead of a minified web stack trace. Pass a configuredDwAlertsintoDwCoreand it just works; custom policies plug in viaDwConfig.onErrorReport. - Connection-aware error handling — network blips become toasts, not
alerts (
dwReportingOnFailedCall, streaming error classifier).
Quick start #
Your app declares the core once, typed with its own Serverpod Client and user
model, and reaches it anywhere as dw:
/// Declared by the app — the framework does not export a `dw` singleton for you.
late final DwCore<Client, UserProfile> dw;
void initDwCore({required String backendUrl}) {
dw = DwCore<Client, UserProfile>(
config: DwConfig(
defaultModelGetter: DwRepository.getDefault,
appVersion: '1.0.0',
),
client: Client(
backendUrl,
// Connection blips become a toast; everything else enters the error
// pipeline with `endpoint.method` attached.
onFailedCall: dwReportingOnFailedCall(
onConnectionError: (_, _) => dw.notify.error('Network error'),
),
)..authKeyProvider = DwAuthenticationKeyManager(),
dwAlerts: DwAlerts.init(telegramConfig: myAlertsConfig),
getUserId: (userProfile) => userProfile?.id,
);
}
// A live list in a widget:
ref.watchModelList<NewsPost>().dwBuildListAsync(
loadingItemsCount: 5,
childBuilder: (posts) => ListView(...),
);
This package re-exports dartway_flutter
(app bootstrap, guarded actions, notifications — no design system) — one import
covers the standard app surface. The backend counterpart is
dartway_serverpod_core_server.
See the canonical example app in the
DartWay monorepo (example/).