csdcorp / speech_to_text

A Flutter plugin that exposes device specific text to speech recognition capability.
BSD 3-Clause "New" or "Revised" License
348 stars 217 forks source link

Compilation fails with 6.5.1 because of multiple ListenMode imports #478

Closed rjahn closed 3 months ago

rjahn commented 3 months ago

Got an error today because of:

Error (Xcode): ../../../../../../../../../.pub-cache/hosted/pub.dev/speech_to_text-6.5.1/lib/speech_to_text_provider.dart:8:1: Error: 'ListenMode' is imported from both 'package:speech_to_text/speech_to_text.dart' and 'package:speech_to_text_platform_interface/speech_to_text_platform_interface.dart'.

luskan commented 3 months ago

I confirm, I switched to ^6.6.0-dev and it compiles fine. I see this issue was fixed for dev branch in this commit few days ago: https://github.com/csdcorp/speech_to_text/commit/874e22fd95dc7282aa6ea1cd94ec764ce6ded07b . The problem occurs because 6.5.1 uses speech_to_text_platform_interface as:

speech_to_text_platform_interface: ^2.1.0

and it will auto upgrade to 2.2.0 after deletion of pubspec.lock

sowens-csd commented 3 months ago

@luskan thank you! You're right of course, that's where my mistake lies. I should have done the platform interface as a 2.x.x release instead of 1.x.x. Unfortunately the only fix now is to get a full release of the 6.6.x branch out.

luskan commented 3 months ago

6.5.1 does compile for me with following overrides:

dependencies: speech_to_text: ^6.5.1

dependency_overrides: speech_to_text_macos: 1.0.2 speech_to_text_platform_interface: 2.1.0

sowens-csd commented 3 months ago

Those overrides make sense as a temporary fix to get 6.5.1 working in your project.

rjahn commented 3 months ago

I confirm. Is working with overrides. Good enough as temporary fix.

@sowens-csd You could create a 6.5.2 and a _fix version for dependencies? The release of 6.6.x is a bigger step!

sowens-csd commented 3 months ago

@rjahn good thought.

sowens-csd commented 3 months ago

I'm trying to get a 6.5.2 fix done. I thought if I spec'd 2.1.0 instead of ^2.1.0 that it should limit it to that explicit version but it doesn't seem to work. No matter what I try it still doesn't recognize the method signature of the listen method as correct. It continues to complain:

error • 'SpeechToTextMacOS.listen' ('Future<bool> Function({int listenMode, String? localeId, dynamic onDevice, dynamic partialResults, dynamic sampleRate})') isn't a
         valid override of 'SpeechToTextPlatform.listen' ('Future<bool> Function({int listenMode, String? localeId, dynamic onDevice, SpeechListenOptions? options,
         dynamic partialResults, dynamic sampleRate})') • lib/speech_to_text_macos.dart:93:16 • invalid_override
rjahn commented 3 months ago

Do you have multiple projects and do you use dependency overrides? Be sure that the overrides are in the correct project.

luskan commented 3 months ago

This problem occured on our server builds, locally I couldnt reproduce it until I deleted pubspec.lock, my later experimetation involved changes to pubspec.yaml and then:

rm pubspec.lock flutter clean flutter pub get

and then rebuild project

if that is important I am on flutter: 3.13.9

sowens-csd commented 3 months ago

I've just pushed 6.6.0 which should fix the issue. If anyone has a chance to try it please let me know. I tried to create a working 6.5.2 but I've given up. Although 6.6.0 deprecates several options on listen your existing code should work unchanged until you choose to upgrade to remove the deprecations.

rjahn commented 3 months ago

6.6.0 is working without dep overrides - thanks for your time!

luskan commented 3 months ago

I confirm, 6.6.0 without dep overrides, works.