首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“错误处理'checkPlatformOverride'”应用程序在运行中崩溃

“错误处理'checkPlatformOverride'”应用程序在运行中崩溃
EN

Stack Overflow用户
提问于 2021-09-13 22:26:05
回答 1查看 88关注 0票数 3

我很难让这个包裹在我的项目上工作。按照他们的文档中给出的示例,我能够找到我认为是功能性的东西,但在模拟器上启动应用程序时,它会崩溃,并出现以下错误:

代码语言:javascript
复制
Error handling 'checkPlatformOverride' custom request: method not available: ext.flutter.platformOverride
Error handling 'checkBrightnessOverride' custom request: method not available: ext.flutter.brightnessOverride
Error handling 'serviceExtension' custom request: method not available: ext.flutter.inspector.setPubRootDirectories
Error handling 'checkIsWidgetCreationTracked' custom request: method not available: ext.flutter.inspector.isWidgetCreationTracked

下面是实现包的主要代码块:

代码语言:javascript
复制
import 'package:flutter/material.dart';
import 'package:speech_to_text/speech_to_text.dart';
import 'package:speech_to_text/speech_recognition_result.dart';

class CustomNav extends StatefulWidget {
  List<Widget> screens;
  int currentScreensIndex;
  Function(int) onScreenChange;

  //list of screens and the starting index (initial _currentScreensIndex)
  CustomNav({
    required this.screens,
    required this.currentScreensIndex,
    required this.onScreenChange,
  });

  @override
  _CustomNavState createState() => _CustomNavState();
}

class _CustomNavState extends State<CustomNav> {
  SpeechToText _speechToText = SpeechToText();
  bool _speechEnabled = false;
  String _lastWords = "";

  //this is called once the speech button is pressed
  activateStt() async {
    await _speechToText.listen(onResult: _onSpeechResult);
    setState(() {});
  }

  void _onSpeechResult(SpeechRecognitionResult result) {
    setState(() {
      _lastWords = result.recognizedWords;
    });
  }

  @override
  void initState() {
    super.initState();
    _initSpeech();
  }

  void _initSpeech() async {
    _speechEnabled = await _speechToText.initialize();
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    double width = MediaQuery.of(context).size.width;

    return Container(
      color: Colors.white,
      width: width,
      height: 100,
      //row of buttons
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: [
          //onScreenChange method calls is where the logic takes place
          IconButton(
              onPressed: () {
                widget.onScreenChange(0);
              },
              icon: Icon(Icons.home_outlined)),
          ElevatedButton(
              style: ElevatedButton.styleFrom(
                  primary: Theme.of(context).accentColor,
                  minimumSize: Size(60, 60),
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(25.0)),
                  elevation: 4,
                  shadowColor: Theme.of(context).accentColor),
              onPressed: () {
                //activate a method that record audio then converts it to text.
                activateStt();
              },
              child: Icon(Icons.mic, color: Colors.white)),
          IconButton(
              onPressed: () {
                widget.onScreenChange(2);
              },
              icon: Icon(Icons.view_sidebar))
        ],
      ),
      //could add spacing here
    );
  }
}

到目前为止,我已经尝试过:

  • 更新颤振
  • 颤振清洁
  • 颤栗的医生(一切都好)
  • 从vs代码和终端发射

没有这些尝试的解决方案,任何帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

发布于 2021-09-22 13:27:15

检查是否是插件版本的问题。

代码语言:javascript
复制
speech_to_text: any
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69169741

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档