Skip to content

Commit 5f74616

Browse files
authored
Merge pull request #1 from HugoSart/main
Update isolate_error_integration.dart
2 parents a2196bd + 80aa027 commit 5f74616

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

dart/lib/src/isolate_error_integration.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@ class IsolateErrorIntegration extends Integration {
1414

1515
@override
1616
FutureOr<void> call(Hub hub, SentryOptions options) async {
17-
_receivePort = _createPort(hub, options);
18-
19-
Isolate.current.addErrorListener(_receivePort!.sendPort);
20-
17+
final safeReceivePort = _receivePort = _createPort(hub, options);
18+
Isolate.current.addErrorListener(safeReceivePort.sendPort);
2119
options.sdk.addIntegration('isolateErrorIntegration');
2220
}
2321

2422
@override
2523
void close() {
2624
if (_receivePort != null) {
27-
_receivePort!.close();
28-
Isolate.current.removeErrorListener(_receivePort!.sendPort);
25+
final safeReceivePort = _receivePort!;
26+
safeReceivePort.close();
27+
Isolate.current.removeErrorListener(safeReceivePort.sendPort);
2928
}
3029
}
3130
}

0 commit comments

Comments
 (0)