Flutter "Error handling 'checkPlatformOverride'" app crashing on run

Viewed 82

I'm having an issue getting this package to work on my project. Following the example given in their docs I was able to get to what I thought would be functional but upon launching the application on a simulator, it crashes with the following error:

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

Heres the main chunk of code where the package was implemented:

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
    );
  }
}

So far I have tried:

  • updating flutter
  • flutter clean
  • flutter doctor (all fine)
  • launching from vs code and from terminal

No luck with these attempted solutions, any help is greatly appreciated.

1 Answers

Check if it's the problem of plugin version.

speech_to_text: any
Related