Skip to content
Prev Previous commit
Next Next commit
update
  • Loading branch information
buenaflor committed Jan 25, 2024
commit 1e13b3d9f95aa2e3f7e6bdc514f429e1dcb94bc6
10 changes: 4 additions & 6 deletions flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
Future<void> main() async {
await setupSentry(
() => runApp(
SentryScreenshotWidget(
child: SentryUserInteractionWidget(
child: DefaultAssetBundle(
bundle: SentryAssetBundle(),
child: const MyApp(),
),
SentryWidget(
child: DefaultAssetBundle(
bundle: SentryAssetBundle(),
child: const MyApp(),
),
),
),
Expand Down
1 change: 1 addition & 0 deletions flutter/lib/sentry_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export 'src/screenshot/sentry_screenshot_widget.dart';
export 'src/screenshot/sentry_screenshot_quality.dart';
export 'src/user_interaction/sentry_user_interaction_widget.dart';
export 'src/binding_wrapper.dart';
export 'src/sentry_widget.dart';
9 changes: 6 additions & 3 deletions flutter/lib/src/sentry_widget.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import 'package:flutter/cupertino.dart';
import 'package:meta/meta.dart';
import '../sentry_flutter.dart';

/// A central widget that contains the Sentry widgets.
class SentryWidget extends StatefulWidget {
const SentryWidget({super.key, required this.child});

late final Hub _hub;
final Widget child;

SentryWidget({super.key, required this.child, @internal Hub? hub})
: _hub = hub ?? HubAdapter();

@override
_SentryWidgetState createState() => _SentryWidgetState();
}
Expand All @@ -32,7 +35,7 @@ class _SentryWidgetState extends State<SentryWidget> {
Widget _maybeWrapUserInteractionWidget(Widget child) {
if (_options.enableUserInteractionTracing ||
_options.enableUserInteractionBreadcrumbs) {
return SentryUserInteractionWidget(child: child);
return SentryUserInteractionWidget(hub: widget._hub, child: child);
}
return child;
}
Expand Down