Skip to content

Commit c07c8f1

Browse files
authored
fix(aws_common): Use isA for JS interop type check in catch clause (#6859)
Replace the typed catch clause `on ProgressEvent catch (e)` with an inline pattern that casts to `JSAny?` and uses `isA<ProgressEvent>()` for the type check. This avoids the `invalid_runtime_check_with_js_interop_types` lint introduced in Dart 3.12 beta, which flags catch clauses and `is` checks using JS interop types as potentially platform-inconsistent. The `as JSAny?` cast is a zero-cost extension type cast, and `isA` is the Dart-recommended approach for runtime-checking JS interop types.
1 parent 6ccc39f commit c07c8f1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/aws_common/lib/src/io/aws_file_platform_html.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ class AWSFilePlatform extends AWSFile {
179179
late http.Response response;
180180
try {
181181
response = await BrowserClient().get(Uri.parse(path));
182-
} on ProgressEvent catch (e) {
183-
if (e.type == 'error') {
182+
} on Object catch (e) {
183+
final jsError = e as JSAny?;
184+
if (jsError.isA<ProgressEvent>() &&
185+
(jsError as ProgressEvent).type == 'error') {
184186
throw const InvalidFileException(
185187
message: 'Could resolve file blob from provide path.',
186188
recoverySuggestion:

0 commit comments

Comments
 (0)