Flutter Voice Search

pub.dev

Add voice input to a Flutter search with one widget. VoiceSearchButton opens a panel with live transcription and a microphone animation driven by the input level. Hold the button and release to search, or tap it and select Search when you finish speaking. The app receives the final text through onResult.

The widget supports Android, iOS, and macOS. Its labels follow the app locale in English, Spanish, and Portuguese. Speech recognition uses the system dictation language and the device's recognition service.

Install

flutter pub add flutter_voice_search

Configure permissions in the host app for each target you ship. Rebuild the app after editing native configuration.

Android

Add these entries inside the root <manifest> in android/app/src/main/AndroidManifest.xml. If you already have a <queries> block, add the intent to that block.

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />

<queries>
    <intent>
        <action android:name="android.speech.RecognitionService" />
    </intent>
</queries>

iOS and macOS

Add the two usage descriptions to ios/Runner/Info.plist or macos/Runner/Info.plist, inside the root <dict>. Tailor the text to your app.

<key>NSMicrophoneUsageDescription</key>
<string>Use your microphone to enter search terms by voice.</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>Convert your speech into text for the search field.</string>

For a sandboxed macOS app, add audio input and network client access inside the root <dict> in macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements.

<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>

Use

Place the button under a Material app navigator, for example in a search field's trailing slot. The widget handles the panel, permission requests, transcription, cancellation, and microphone cleanup. Your callback decides how to use the query.

import 'package:flutter/material.dart';
import 'package:flutter_voice_search/flutter_voice_search.dart';

// Inside the state that owns your searchController.
TextField(
  controller: searchController,
  decoration: InputDecoration(
    hintText: 'Search',
    suffixIcon: VoiceSearchButton.isSupported
        ? VoiceSearchButton(
            onResult: (query) {
              searchController.value = TextEditingValue(
                text: query,
                selection: TextSelection.collapsed(offset: query.length),
              );
              // Call your search function here if you rely on onChanged.
            },
          )
        : null,
  ),
)

onResult is called once with a nonempty query. Cancellation, permission denial, and empty recognition preserve the current search. VoiceSearchButton.isSupported reports platform support. Actual recognition still depends on the device, its configured language, permissions, and the availability of its speech service.

Example

The example app includes native permissions and a searchable list. Run it on a device with speech recognition and a microphone.

cd example
flutter run

For package checks, run flutter test and flutter analyze from the repository root.

Audio and licensing

The package uses the device's speech recognition service through speech_to_text. The system service may process speech online depending on the device and language. The package does not store audio or keep transcript history.

Released under the MIT License.

Libraries

A microphone button that captures speech and returns a search query.