saropa_drift_advisor library

Debug-only HTTP server that exposes SQLite/Drift table data as JSON and a minimal web viewer.

Architecture: The package is dependency-injection friendly: it does not depend on drift. You supply a DriftDebugQuery that runs SQL; the server uses it for table listing, table data, schema, and optional read-only SQL runner. One server per process; DriftDebugServer.stop clears state so DriftDebugServer.start can be called again (e.g. in tests).

Use from any Flutter or Dart app that has a SQLite (or Drift) database. Add the package (from pub.dev or a path dependency), then start the server with DriftDebugServer.start, passing a DriftDebugQuery callback that runs SQL and returns rows as maps.

Public API

See the package README for HTTP endpoints, UI features, and optional auth for dev tunnels.

Classes

DriftDebugErrorLogger
Best-practice error and message logger for the Drift debug server.

Mixins

DriftDebugServer
Debug-only HTTP server (stub when dart:io unavailable).

Extensions

StartDriftViewerExtension on Object
Convenience API for Drift apps: await myDb.startDriftViewer(...).

Typedefs

DriftDebugGetDatabaseBytes = Future<List<int>> Function()
Optional callback that returns the raw SQLite database file bytes.
DriftDebugLoggerCallbacks = ({_ErrorCallback error, _LogCallback log})
Type for the pair of log and error callbacks returned by DriftDebugErrorLogger.callbacks.
DriftDebugOnError = void Function(Object error, StackTrace stack)
Optional callback for errors (and optional stack trace).
DriftDebugOnLog = void Function(String message)
Optional callback for log messages.
DriftDebugQuery = Future<List<Map<String, dynamic>>> Function(String sql)
Callback that runs a single SQL query and returns rows as list of maps.
DriftDebugWriteQuery = Future<void> Function(String sql)
Optional callback for write queries (INSERT/UPDATE/DELETE). Debug-only: used exclusively by the import endpoint.