diff --git a/build_tools/SDK_VERSION b/build_tools/SDK_VERSION index eca690e..7b59a5c 100644 --- a/build_tools/SDK_VERSION +++ b/build_tools/SDK_VERSION @@ -1 +1 @@ -3.0.5 +3.10.2 diff --git a/rollbar_flutter/example/android/build.gradle b/rollbar_flutter/example/android/build.gradle index e29a443..2eb4306 100644 --- a/rollbar_flutter/example/android/build.gradle +++ b/rollbar_flutter/example/android/build.gradle @@ -24,6 +24,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/rollbar_flutter/example/ios/Runner.xcodeproj/project.pbxproj b/rollbar_flutter/example/ios/Runner.xcodeproj/project.pbxproj index a074221..a17b87a 100644 --- a/rollbar_flutter/example/ios/Runner.xcodeproj/project.pbxproj +++ b/rollbar_flutter/example/ios/Runner.xcodeproj/project.pbxproj @@ -215,6 +215,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/rollbar_flutter/lib/src/rollbar.dart b/rollbar_flutter/lib/src/rollbar.dart index ba76193..35c4482 100644 --- a/rollbar_flutter/lib/src/rollbar.dart +++ b/rollbar_flutter/lib/src/rollbar.dart @@ -1,8 +1,9 @@ import 'dart:async'; -import 'package:meta/meta.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; +import 'package:meta/meta.dart'; import 'package:rollbar_dart/rollbar.dart'; @@ -30,29 +31,37 @@ class RollbarFlutter { Config config, RollbarClosure appRunner, ) async { - WidgetsFlutterBinding.ensureInitialized(); + if (!config.handleUncaughtErrors) { + WidgetsFlutterBinding.ensureInitialized(); - await Rollbar.run(config.copyWith( - framework: 'flutter', - persistencePath: await _platform.persistencePath, - transformer: (_) => PlatformTransformer(), - )); + await _run(config, appRunner, null); - if (!config.handleUncaughtErrors) { - await _platform.initialize(config: config); - await appRunner(); return; } await runZonedGuarded(() async { WidgetsFlutterBinding.ensureInitialized(); - FlutterError.onError = RollbarFlutterError.onError; - - await _platform.initialize(config: config); - await appRunner(); + await _run(config, appRunner, RollbarFlutterError.onError); }, (exception, stackTrace) { Rollbar.error(exception, stackTrace); }); } + + static Future _run( + Config config, + RollbarClosure appRunner, + FlutterExceptionHandler? onError, + ) async { + await Rollbar.run(config.copyWith( + framework: 'flutter', + persistencePath: await _platform.persistencePath, + transformer: (_) => PlatformTransformer(), + )); + + FlutterError.onError ??= onError; + + await _platform.initialize(config: config); + await appRunner(); + } } diff --git a/rollbar_flutter/test/rollbar_flutter_test.dart b/rollbar_flutter/test/rollbar_flutter_test.dart index 3aaf635..3a8988c 100644 --- a/rollbar_flutter/test/rollbar_flutter_test.dart +++ b/rollbar_flutter/test/rollbar_flutter_test.dart @@ -20,7 +20,8 @@ void main() { when(sender.send(any)).thenAnswer((_) async => true); callsReceived = []; - channel.setMockMethodCallHandler((methodCall) async { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, (methodCall) async { callsReceived.add(methodCall); return '42'; }); @@ -28,7 +29,8 @@ void main() { tearDown(() { debugDefaultTargetPlatformOverride = null; - channel.setMockMethodCallHandler(null); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, null); }); test('Initialize platform component when running application', () async {