Talaria

Docs / SDKs / Flutter

Flutter

Flutter apps on top of the Dart SDK — global error hooks and widget-aware capture.

Built on the Dart SDK. Use this guide for Flutter-specific error hooks and app bootstrap.

Install

Add the package to your pubspec.yaml, then run flutter pub get.

pubspec.yamlyaml
dependencies:
  talaria: ^1.0.0

Configure

Use a project API key (tal_live_…). Pass keys via --dart-define or your flavor config — never hardcode them in source.

talaria.dartdart
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:talaria/talaria.dart';

final client = TalariaClient(
  dsn: const String.fromEnvironment(
    'TALARIA_DSN',
    defaultValue: 'https://api.newtalaria.com',
  ),
  apiKey: const String.fromEnvironment('TALARIA_API_KEY'),
  environment: const String.fromEnvironment(
    'APP_ENV',
    defaultValue: 'production',
  ),
  release: const String.fromEnvironment('APP_RELEASE'),
);

Global error hooks

Wire Flutter and platform dispatchers so uncaught errors become Talaria events:

main.dartdart
void main() {
  FlutterError.onError = (details) {
    client.captureException(
      details.exception,
      stackTrace: details.stack,
    );
    FlutterError.presentError(details);
  };

  PlatformDispatcher.instance.onError = (error, stack) {
    client.captureException(error, stackTrace: stack);
    return true;
  };

  runApp(const MyApp());
}

Zone-guarded bootstrap

Optionally wrap runApp in a zone so async errors outside the framework are captured too:

main.dartdart
void main() {
  runZonedGuarded(
    () {
      WidgetsFlutterBinding.ensureInitialized();
      runApp(const MyApp());
    },
    (error, stack) {
      client.captureException(error, stackTrace: stack);
    },
  );
}

Capture exceptions

dart
try {
  await riskyOperation();
} catch (error, stackTrace) {
  await client.captureException(
    error,
    stackTrace: stackTrace,
    tags: {'screen': 'checkout'},
  );
  rethrow;
}

Environments & releases

Map build flavors / --dart-define values into environment and release so the dashboard can filter issues and correlate deploys.

Troubleshooting

  • 401/403 — check API key and that it belongs to the target project.
  • No issue appears — confirm environment filter in the dashboard.
  • Rejected events — validate JSON shape against the API overview.

Need pure Dart (no Flutter)? See the Dart SDK or send events over HTTP via the API overview.