简体   繁体   English

dart:tml 和 dart:js 未找到错误抖动

[英]dart:tml and dart:js not found error flutter

I am trying to make a speech to text and text to speech feature in my chat app for making voice messages.我正在尝试在我的聊天应用程序中对文本进行语音和文本到语音功能,以制作语音消息。 I was following this documentation completely https://pub.dev/packages/flutter_tts/example .我完全遵循此文档https://pub.dev/packages/flutter_tts/example But I had to import another library called flutter_tts_web.dart .I thought it should not be a big deal but it seems like it is causing the big error.但是我不得不导入另一个名为 flutter_tts_web.dart 的库。我认为这应该不是什么大问题,但似乎它导致了大错误。 Here is the stacktrace这是堆栈跟踪

../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:2:8: Error: Not found: 'dart:html'
import 'dart:html' as html;
       ^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:3:8: Error: Not found: 'dart:js'
import 'dart:js';
       ^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:31:3: Error: Type 'html.SpeechSynthesis' not found.
  html.SpeechSynthesis synth;
  ^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:32:3: Error: Type 'html.SpeechSynthesisUtterance' not found.
  html.SpeechSynthesisUtterance utterance;
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:31:8: Error: 'SpeechSynthesis' isn't a type.
  html.SpeechSynthesis synth;
       ^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:32:8: Error: 'SpeechSynthesisUtterance' isn't a type.
  html.SpeechSynthesisUtterance utterance;
       ^^^^^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:37:17: Error: Method not found: 'SpeechSynthesisUtterance'.
    utterance = html.SpeechSynthesisUtterance();
                ^^^^^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:38:18: Error: Getter not found: 'window'.
    synth = html.window.speechSynthesis;
                 ^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:156:63: Error: 'JsArray' isn't a type.
        context['speechSynthesis'].callMethod('getVoices') as JsArray<dynamic>;
                                                              ^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:156:9: Error: The getter 'context' isn't defined for the class 'FlutterTtsPlugin'.
 - 'FlutterTtsPlugin' is from 'package:flutter_tts/flutter_tts_web.dart' ('../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'context'.
        context['speechSynthesis'].callMethod('getVoices') as JsArray<dynamic>;
        ^^^^^^^
/C:/flutter/packages/flutter_web_plugins/lib/src/plugin_registry.dart:29:5: Error: Method not found: 'webOnlySetPluginHandler'.
    ui.webOnlySetPluginHandler(_binaryMessenger.handlePlatformMessage);
    ^^^^^^^^^^^^^^^^^^^^^^^
Unhandled exception:
FileSystemException(uri=
org-dartlang-untranslatable-uri:dart%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs)
#0      StandardFileSystem.entityForUri (package:front_end/src/api_proto
type/standard_file_system.dart:33:7)
#1      asFileUri (package:vm/kernel_front_end.dart:659:37)
#2      writeDepfile (package:vm/kernel_front_end.dart:853:21)
<asynchronous suspension>
#3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:574:15)
<asynchronous suspension>
#4      _FlutterFrontendCompiler.compile (package:flutter_frontend_server/server.dart:43:22)
#5      starter (package:flutter_frontend_server/server.dart:182:27)
#6      main (file:///C:/b/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:9:30)
#7      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#8      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)



FAILURE: Build failed with an exception.

* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 896

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 38s
Exception: Gradle task assembleDebug failed with exit code 1

I tried to remove the file but the variable Tts State depends on the web file.我试图删除该文件,但变量 Tts State 取决于网络文件。 A;so tried flutter clean and switching to beta chanel. A;所以尝试flutter clean并切换到beta chanel。 Please help as soon as possible as this is for a hackathon and I have 8 hours left.请尽快提供帮助,因为这是一个黑客马拉松,我还有 8 小时。 I'll provide any code neccessary almost instantly我会立即提供任何必要的代码

我认为这是因为未安装 dart,请确保您正确安装了 dart,并在安装 dart 后使用以下命令。

pub get

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM