Register service in dependency injection and document public API
epic-speech-to-text-input-speech-engine-task-010 — Register SpeechRecognitionService in the Riverpod provider graph as a singleton scoped to the dictation feature. Write DartDoc comments on all public methods and event types. Produce a brief integration guide (inline comments or a code example file) describing how TranscriptionStateManager should subscribe to the event stream, including recommended error handling patterns for consumers.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 9 - 22 tasks
Can start after Tier 8 completes
Implementation Notes
Declare the provider in a dedicated providers file (e.g., lib/features/dictation/providers/speech_recognition_providers.dart) following the project's existing Riverpod provider file convention. Use Provider
DartDoc style should match the existing codebase style; use triple-slash comments (///) and avoid redundant @author tags. Ensure the guide mentions that SpeechRecognitionService is not safe to call from a background isolate.
Testing Requirements
Unit tests are not the primary deliverable for this documentation task, but a compile-time smoke test is required: the integration guide's code example file must compile without errors (dartanalyzer clean). Write one widget test or unit test that reads the speechRecognitionServiceProvider from a ProviderContainer and asserts it returns a non-null SpeechRecognitionService instance, confirming DI registration is valid. Total new test coverage target: 1 test, 100% pass rate.
The speech_to_text Flutter package delegates accuracy entirely to the OS-native engine. Norwegian accuracy for domain-specific vocabulary (medical terms, organisation names, accessibility terminology) may fall below the 85% acceptance threshold on older devices or in noisy environments, causing user frustration and manual correction overhead that negates the time saving.
Mitigation & Contingency
Mitigation: Configure the SpeechRecognitionService with Norwegian as the explicit locale and test against a representative corpus of peer mentoring vocabulary on target devices. Expose locale switching so users can fallback to Bokmål vs Nynorsk. Clearly set user expectations in the UI that transcription is a starting point for editing, not a finished product.
Contingency: If accuracy is consistently below threshold on specific device/OS combinations, add a device-capability check that hides the dictation button with an explanatory message rather than offering a degraded experience. Document affected device models for QA and org contacts.
The speech_to_text Flutter package is a third-party dependency that may introduce breaking API changes or deprecations on major version upgrades, requiring rework of SpeechRecognitionService when Flutter or platform OS versions are updated.
Mitigation & Contingency
Mitigation: Wrap all speech_to_text API calls behind the SpeechRecognitionService interface so that package changes are isolated to one file. Pin the package version in pubspec.yaml and review changelogs before any upgrade. Write integration tests that exercise the package contract so regressions are caught immediately.
Contingency: If the package is abandoned or has unresolvable issues, NativeSpeechApiBridge already provides the platform-channel abstraction needed to implement a direct plugin replacement with minimal changes to SpeechRecognitionService.