Sentry integration for drift package

package build pub likes popularity pub points
sentry_drift build pub package likes popularity pub points

Integration for the drift package.


  • Sign up for a account and get a DSN at

  • Follow the installing instructions on

  • Initialize the Sentry SDK using the DSN issued by

  • Call...

import 'package:drift/drift.dart';
import 'package:drift/native.dart';
import 'package:sentry/sentry.dart';
import 'package:sentry_drift/sentry_drift.dart';

import 'your_database.dart';

Future<void> main() async {
  // ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at
  const dsn =

  await Sentry.init(
    (options) {
      options.dsn = dsn;
      options.tracesSampleRate = 1.0;
      options.debug = true;
    appRunner: runApp, // Init your App.

Future<void> runApp() async {
  final tr =
      Sentry.startTransaction('drift', 'op', bindToScope: true);
  final executor = SentryQueryExecutor(
    () => NativeDatabase.memory(),
    databaseName: 'my_db_name',
  final db = AppDatabase(executor);

  await db.into(db.todoItems).insert(
          title: 'This is a test thing',
          content: 'test',

  final items = await;

  await db.close();

  await tr.finish(status: const SpanStatus.ok());


  • Flutter docs
  • Dart docs
  • Discussions
  • Discord Chat
  • Stack Overflow
  • Twitter Follow