Skip to content

Commit

Permalink
fix: make FFI dependency conditional (web/vm)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Sep 18, 2023
1 parent a3d53ae commit f2f6301
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions flutter/lib/src/native/factory.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'factory_real.dart' if (dart.library.html) 'factory_web.dart';
14 changes: 14 additions & 0 deletions flutter/lib/src/native/factory_real.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:flutter/services.dart';

import '../../sentry_flutter.dart';
import 'cocoa/sentry_native_cocoa.dart';
import 'sentry_native_binding.dart';
import 'sentry_native_channel.dart';

SentryNativeBinding createBinding(PlatformChecker pc, MethodChannel channel) {
if (pc.platform.isIOS || pc.platform.isMacOS) {
return SentryNativeCocoa(channel);
} else {
return SentryNativeChannel(channel);
}
}
9 changes: 9 additions & 0 deletions flutter/lib/src/native/factory_web.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:flutter/services.dart';

import '../../sentry_flutter.dart';
import 'sentry_native_binding.dart';

// This isn't actually called, see SentryFlutter.init()
SentryNativeBinding createBinding(PlatformChecker pc, MethodChannel channel) {
throw UnsupportedError("Native binding is not supported on this platform.");
}
15 changes: 2 additions & 13 deletions flutter/lib/src/sentry_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import 'event_processor/android_platform_exception_event_processor.dart';
import 'event_processor/flutter_exception_event_processor.dart';
import 'event_processor/platform_exception_event_processor.dart';
import 'integrations/screenshot_integration.dart';
import 'native/cocoa/sentry_native_cocoa.dart';
import 'native/factory.dart';
import 'native/native_scope_observer.dart';
import 'native/sentry_native_channel.dart';
import 'profiling.dart';
import 'renderer/renderer.dart';
import 'native/sentry_native.dart';
import 'native/sentry_native_binding.dart';

import 'integrations/integrations.dart';
import 'event_processor/flutter_enricher_event_processor.dart';
Expand Down Expand Up @@ -51,16 +49,7 @@ mixin SentryFlutter {
}

if (flutterOptions.platformChecker.hasNativeIntegration) {
late final SentryNativeBinding binding;

// Set a default native channel to the singleton SentryNative instance.
if (flutterOptions.platformChecker.platform.isIOS ||
flutterOptions.platformChecker.platform.isMacOS) {
binding = SentryNativeCocoa(channel);
} else {
binding = SentryNativeChannel(channel);
}

final binding = createBinding(flutterOptions.platformChecker, channel);
_native = SentryNative(flutterOptions, binding);
}

Expand Down

0 comments on commit f2f6301

Please sign in to comment.