Flutter error tracking installation
Contents
We currently don't support the following features:
- No de-obfuscating stacktraces from obfuscated builds (--obfuscate and --split-debug-info) for Dart code
- No de-obfuscating stacktraces when isMinifyEnabled is enabled for Java/Kotlin code
- No Source code context associated with an exception
- No native iOS exception capture
- No native C/C++ exception capture on Android (Java/Kotlin only)
- No background isolate error capture
- No Flutter web support
These features will be added in future releases.
- 1
Install PostHog Flutter SDK
RequiredSDK version requirementA minimum SDK version of 5.9.0 is required, but we recommend keeping up to date with the latest version to ensure you have all of error tracking's features.
Manual installation
First, add
posthog_flutterto yourpubspec.yaml:pubspec.yamlThen complete the manual setup for each platform:
Android setup
Add your PostHog configuration to your
AndroidManifest.xmlfile located in theandroid/app/src/main:android/app/src/main/AndroidManifest.xmlYou'll also need to update the minimum Android SDK version to
21inandroid/app/build.gradle:android/app/build.gradleiOS setup
Add your PostHog configuration to the
Info.plistfile located in theios/Runnerdirectory:ios/Runner/Info.plistYou'll need to set the minimum platform version to iOS 13.0 in your Podfile:
ios/PodfileDart setup
Then setup the SDK manually:
Dart - 2
Set up exception autocapture
RecommendedClient-side configuration onlyThis configuration is client-side only. Support for remote configuration in the error tracking settings will be added in a future release.
You can autocapture exceptions by configuring the
errorTrackingConfigwhen setting up PostHog:DartConfiguration options:
captureFlutterErrors: Captures Flutter framework errors (FlutterError.onError)capturePlatformDispatcherErrors: Captures Dart runtime errors (PlatformDispatcher.onError)captureIsolateErrors: Captures errors from main isolatecaptureNativeExceptions: Captures native exceptions (Android only - Java/Kotlin exceptions)captureSilentFlutterErrors: Captures Flutter errors that are marked as silent (default: false)
- 3
Manually capture exceptions
OptionalBasic usage
You can manually capture exceptions using the
captureExceptionmethod:DartThis is helpful if you've built your own error handling logic or want to capture exceptions that are handled by your application code.
Error tracking configuration
You can configure error tracking behavior when setting up PostHog:
DartConfiguration options:
inAppIncludes: List of package names to be considered inApp frames (takes precedence over excludes)inAppExcludes: List of package names to be excluded from inApp framesinAppByDefault: Whether frames are considered inApp by default when their origin cannot be determined
inAppframes are stack trace frames that belong to your application code (as opposed to third-party libraries or system code). These are highlighted in the PostHog error tracking interface to help you focus on the relevant parts of the stack trace.

