Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 0 additions & 3 deletions flutter/example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 97JCY7859U;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -498,7 +497,6 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 97JCY7859U;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -529,7 +527,6 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 97JCY7859U;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down
211 changes: 96 additions & 115 deletions flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import 'dart:isolate';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

import 'package:sentry/sentry.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:universal_platform/universal_platform.dart';

const String _release =
Expand Down Expand Up @@ -36,20 +35,23 @@ Future<void> main() async {
}, (error, stackTrace) async {
print('Capture from runZonedGuarded $error');
final event = Event(
exception: error,
stackTrace: stackTrace,
// release is required on Web to match the source maps
release: _release);
exception: error,
stackTrace: stackTrace,
// release is required on Web to match the source maps
release: _release,
);
await _sentry.capture(event: event);
});
}

// Candidate API for the SDK
extension IsolateExtensions on Isolate {
void addSentryErrorListener(SentryClient sentry) {
final receivePort = RawReceivePort((dynamic values) async {
await sentry.captureIsolateError(values);
});
final receivePort = RawReceivePort(
(dynamic values) async {
await sentry.captureIsolateError(values);
},
);

Isolate.current.addErrorListener(receivePort.sendPort);
}
Expand Down Expand Up @@ -103,85 +105,60 @@ class _MyAppState extends State<MyApp> {
return;
}

setState(() {
_platformVersion = platformVersion;
});
}

Future<void> init() async {
const platform = MethodChannel('io.sentry.flutter.manchestermaps/kmlLayer');
try {
final dynamic campusMapOverlay =
await platform.invokeMethod<dynamic>('retrieveFileFromUrl');
print(campusMapOverlay);
} on PlatformException catch (error) {
print(error);
}
setState(() => _platformVersion = platformVersion);
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Sentry Flutter Example'),
),
appBar: AppBar(title: const Text('Sentry Flutter Example')),
body: Column(
children: [
Center(
child: Text('Running on: $_platformVersion\n'),
),
const Center(
child: Text('Release: $_release\n'),
),
Center(child: Text('Running on: $_platformVersion\n')),
const Center(child: Text('Release: $_release\n')),
RaisedButton(
child: const Text('Dart: throw null'),
onPressed: () => throw null),
child: const Text('Dart: throw null'),
// Warning : not captured if a debugger is attached
// https://github.com/flutter/flutter/issues/48972
onPressed: () => throw null,
),
RaisedButton(
child: const Text('Dart: assert'),
onPressed: () {
// Only relevant in debug builds
assert(false, 'assert failure');
}),
child: const Text('Dart: assert'),
onPressed: () {
// Only relevant in debug builds
// Warning : not captured if a debugger is attached
// https://github.com/flutter/flutter/issues/48972
assert(false, 'assert failure');
},
),
RaisedButton(
child: const Text('Dart: Fail in microtask.'),
onPressed: () async => {
await Future.microtask(
() => throw StateError('Failure in a microtask'))
}),
child: const Text('Dart: Fail in microtask.'),
onPressed: () async => {
await Future.microtask(
() => throw StateError('Failure in a microtask'),
)
},
),
RaisedButton(
child: const Text('Dart: Fail in isolate'),
onPressed: () async => {
await compute(
(Object _) => throw StateError('from an isolate'),
null)
}),
const PlatformExample()
child: const Text('Dart: Fail in isolate'),
onPressed: () async => {
await compute(
(Object _) => throw StateError('from an isolate'),
null,
)
},
),
if (UniversalPlatform.isIOS) const CocoaExample(),
if (UniversalPlatform.isAndroid) const AndroidExample(),
if (UniversalPlatform.isWeb) const WebExample(),
],
),
),
);
}
}

class PlatformExample extends StatelessWidget {
const PlatformExample({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Column(
children: [
if (UniversalPlatform.isIOS)
const CocoaExample()
else if (UniversalPlatform.isAndroid)
const AndroidExample()
else if (UniversalPlatform.isWeb)
const WebExample()
],
);
}
}

class AndroidExample extends StatelessWidget {
const AndroidExample({Key key}) : super(key: key);

Expand Down Expand Up @@ -239,43 +216,45 @@ class CocoaExample extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Column(children: [
RaisedButton(
child: const Text('Swift fatalError'),
onPressed: () async {
const channel = MethodChannel('example.flutter.sentry.io');
await channel.invokeMethod<void>('fatalError');
},
),
RaisedButton(
child: const Text('Swift Capture NSException'),
onPressed: () async {
const channel = MethodChannel('example.flutter.sentry.io');
await channel.invokeMethod<void>('capture');
},
),
RaisedButton(
child: const Text('Swift Capture message'),
onPressed: () async {
const channel = MethodChannel('example.flutter.sentry.io');
await channel.invokeMethod<void>('capture_message');
},
),
RaisedButton(
child: const Text('Objective-C Throw unhandled exception'),
onPressed: () async {
const channel = MethodChannel('example.flutter.sentry.io');
await channel.invokeMethod<void>('throw');
},
),
RaisedButton(
child: const Text('Objective-C SEGFAULT'),
onPressed: () async {
const channel = MethodChannel('example.flutter.sentry.io');
await channel.invokeMethod<void>('crash');
},
),
]);
return Column(
children: [
RaisedButton(
child: const Text('Swift fatalError'),
onPressed: () async {
const channel = MethodChannel('example.flutter.sentry.io');
await channel.invokeMethod<void>('fatalError');
},
),
RaisedButton(
child: const Text('Swift Capture NSException'),
onPressed: () async {
const channel = MethodChannel('example.flutter.sentry.io');
await channel.invokeMethod<void>('capture');
},
),
RaisedButton(
child: const Text('Swift Capture message'),
onPressed: () async {
const channel = MethodChannel('example.flutter.sentry.io');
await channel.invokeMethod<void>('capture_message');
},
),
RaisedButton(
child: const Text('Objective-C Throw unhandled exception'),
onPressed: () async {
const channel = MethodChannel('example.flutter.sentry.io');
await channel.invokeMethod<void>('throw');
},
),
RaisedButton(
child: const Text('Objective-C SEGFAULT'),
onPressed: () async {
const channel = MethodChannel('example.flutter.sentry.io');
await channel.invokeMethod<void>('crash');
},
),
],
);
}
}

Expand All @@ -284,14 +263,16 @@ class WebExample extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Column(children: [
RaisedButton(
child: const Text('Web: console.log'),
onPressed: () async {
const channel = MethodChannel('example.flutter.sentry.io');
await channel.invokeMethod<void>('console.log');
},
),
]);
return Column(
children: [
RaisedButton(
child: const Text('Web: console.log'),
onPressed: () async {
const channel = MethodChannel('example.flutter.sentry.io');
await channel.invokeMethod<void>('console.log');
},
),
],
);
}
}
1 change: 0 additions & 1 deletion flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dependencies:
sentry_flutter:
path: ../

cupertino_icons: ^0.1.3
universal_platform: ^0.1.3

dev_dependencies:
Expand Down
Loading