Skip to content

Commit

Permalink
fix: add type check to event.data
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenbell committed Aug 1, 2024
1 parent cd8452c commit ed1a1f3
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class WebWebViewControllerCreationParams
// ignore: avoid_unused_constructor_parameters
PlatformWebViewControllerCreationParams params, {
@visibleForTesting
HttpRequestFactory httpRequestFactory = const HttpRequestFactory(),
HttpRequestFactory httpRequestFactory = const HttpRequestFactory(),
}) : this(httpRequestFactory: httpRequestFactory);

static int _nextIFrameId = 0;
Expand Down Expand Up @@ -128,14 +128,18 @@ class WebWebViewController extends PlatformWebViewController {
return;
}

if (event.data == null || event.data is! Map) {
return;
}

// ignore: avoid_dynamic_calls
final String? channelName = event.data?['channel'] as String?;
final String? channelName = event.data['channel'] as String?;
if (channelName != javaScriptChannelParams.name) {
return;
}

// ignore: avoid_dynamic_calls
final String? message = event.data?['message'] as String?;
final String? message = event.data['message'] as String?;
if (message == null) {
return;
}
Expand Down

0 comments on commit ed1a1f3

Please sign in to comment.