Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix a few constructors
  • Loading branch information
fzyzcjy committed Mar 6, 2021
commit 5cb2538954eb5846f3a62579e2a952cb3d6a548d
6 changes: 1 addition & 5 deletions flutter/lib/src/navigation/sentry_navigator_observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ const _navigationKey = 'navigation';
/// - [RouteObserver](https://api.flutter.dev/flutter/widgets/RouteObserver-class.html)
/// - [Navigating with arguments](https://flutter.dev/docs/cookbook/navigation/navigate-with-arguments)
class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
factory SentryNavigatorObserver({Hub? hub}) {
return SentryNavigatorObserver._(hub ?? HubAdapter());
}

SentryNavigatorObserver._(this.hub) : assert(hub != null);
SentryNavigatorObserver({Hub? hub}) : hub = hub ?? HubAdapter();

final Hub hub;

Expand Down
27 changes: 9 additions & 18 deletions flutter/lib/src/widgets_binding_observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ class SentryWidgetsBindingObserver with WidgetsBindingObserver {
SentryWidgetsBindingObserver({
Hub? hub,
required SentryFlutterOptions options,
}) {
_hub = hub ?? HubAdapter();
assert(options != null);
_options = options;
}
}) : _hub = hub ?? HubAdapter(),
_options = options;

late Hub _hub;
late SentryFlutterOptions _options;
final Hub _hub;
final SentryFlutterOptions _options;

/// This method records lifecycle events.
/// It tries to mimic the behavior of ActivityBreadcrumbsIntegration of Sentry
Expand Down Expand Up @@ -87,16 +84,13 @@ class SentryWidgetsBindingObserver with WidgetsBindingObserver {
return;
}
final brightness = WidgetsBinding.instance!.window.platformBrightness;
final brightnessDescription =
brightness == Brightness.dark ? 'dark' : 'light';
final brightnessDescription = brightness == Brightness.dark ? 'dark' : 'light';

_hub.addBreadcrumb(Breadcrumb(
message: 'Platform brightness was changed to $brightnessDescription.',
type: 'system',
category: 'device.event',
data: <String, String>{
'action': 'BRIGHTNESS_CHANGED_TO_${brightnessDescription.toUpperCase()}'
},
data: <String, String>{'action': 'BRIGHTNESS_CHANGED_TO_${brightnessDescription.toUpperCase()}'},
));
}

Expand All @@ -112,9 +106,7 @@ class SentryWidgetsBindingObserver with WidgetsBindingObserver {
message: 'Text scale factor changed to $newTextScaleFactor.',
type: 'system',
category: 'device.event',
data: <String, String>{
'action': 'TEXT_SCALE_CHANGED_TO_$newTextScaleFactor'
},
data: <String, String>{'action': 'TEXT_SCALE_CHANGED_TO_$newTextScaleFactor'},
));
}

Expand All @@ -129,8 +121,7 @@ class SentryWidgetsBindingObserver with WidgetsBindingObserver {
// - https://develop.sentry.dev/sdk/event-payloads/breadcrumbs/
// - https://github.com/getsentry/sentry-java/blob/main/sentry-android-core/src/main/java/io/sentry/android/core/AppComponentsBreadcrumbsIntegration.java#L98-L135
// on why this breadcrumb looks like this.
const message =
'App had memory pressure. This indicates that the operating system '
const message = 'App had memory pressure. This indicates that the operating system '
'would like applications to release caches to free up more memory.';
_hub.addBreadcrumb(Breadcrumb(
message: message,
Expand Down Expand Up @@ -158,7 +149,7 @@ class SentryWidgetsBindingObserver with WidgetsBindingObserver {
return '';
}

/*
/*
These are also methods of `WidgetsBindingObserver` but are currently not
implemented because I'm not sure what to do with them. See the reasoning
for each method. If these methods are implemented the class definition should
Expand Down