diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index 94aaf63ee5f3e..7b93104106298 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -19,3 +19,33 @@ Future main() async { ); } ``` + +### Filtering Screenshots + +You can filter your screenshots by using the `beforeScreenshot` callback. +It is called before taking a screenshot and if the callback returns `false`, the screenshot will not be attached. + +```dart +import 'package:flutter/widgets.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; + +Future main() async { + await SentryFlutter.init( + (options) { + options.dsn = '___PUBLIC_DSN___'; + options.attachScreenshot = true; + options.beforeScreenshot = (event, {hint}) { + // Return false if you don't want to attach the screenshot based on some condition. + return true; + }; + }, + appRunner: () => runApp( + // Wrap your app widget with the [SentryWidget] widget. + SentryWidget( + child: MyApp(), + ), + ), + ); +} +``` +