[darthtml][Regression] Dart 2.13 and above throws SpeechRecognitionResult.item is not a function or method
#47779
Labels
area-web
Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.
library-html
web-dev-compiler
web-triage-0
repro is available
For complete details, see flutter/flutter#86621
Description
When calling
SpeechRecognitionResult.item
in a SpeechRecognition Dart sample on Dart 2.12 using dart html, doesn't throw any errors.However, something changed since 2.13, and the same example throws
SpeechRecognitionResult.item is not a function or method
.Steps to reproduce just using dart example
Using the latest Dart version
dart pub global activate webdev
dart create -t web-simple quickstart
Paste in the code sample below in
main.dart
minimal code dart sample
webdev serve
and open localhost address provided by the CLI into a browser on desktopHello
or any word into the microphone and checkout browser consoleThis line in https://raw.githubusercontent.com/dart-lang/sdk/main/sdk/lib/html/dart2js/html_dart2js.dart throws the error
When checking js source, I noticed older Dart version used to have
let alt = recognitionResult.item(altIndex);
But in later Dart SDK this is
let alt = recognitionResult[$item](altIndex);
When using 2.12 Dart SDK, there is no issue
https://github.com/dart-lang/sdk/releases/tag/2.12.0-285.0.dev
For a Flutter example see flutter/flutter#86621 (comment)
This bug also affects a package csdcorp/speech_to_text#242
The text was updated successfully, but these errors were encountered: