mic_info 0.0.6 copy "mic_info: ^0.0.6" to clipboard
mic_info: ^0.0.6 copied to clipboard

Mic Info Plugin is a Flutter plugin that retrieves information about connected microphones on Android and iOS. It supports detecting built-in, wired (including USB connector microphones), and Bluetoot [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:mic_info/mic_info.dart';
import 'package:mic_info/model/mic_info_model.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  List<MicInfoDevice> mics = <MicInfoDevice>[];
  int index = 0;

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

  void getActive() async {
    mics = await MicInfo.getActiveMicrophones();
    setState(() {
      index = 0;
    });
  }

  void getBluetooth() async {
    mics = await MicInfo.getBluetoothMicrophones();
    setState(() {
      index = 1;
    });
  }

  void getDefault() async {
    mics = await MicInfo.getDefaultMicrophones();
    setState(() {
      index = 2;
    });
  }

  void getWired() async {
    mics = await MicInfo.getWiredMicrophones();
    setState(() {
      index = 3;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Microphone info'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              if (mics.isEmpty)
                const Text('No microphones for the selected category'),
              for (final mic in mics) Text('${mic.productName} (${mic.id})'),
            ],
          ),
        ),
        bottomNavigationBar: BottomNavigationBar(
          onTap: (itemIndex) {
            switch (itemIndex) {
              case 0:
                getActive();
                break;
              case 1:
                getBluetooth();
                break;
              case 2:
                getDefault();
                break;
              case 3:
                getWired();
                break;
            }
          },
          currentIndex: index,
          items: const <BottomNavigationBarItem>[
            BottomNavigationBarItem(
              backgroundColor: Colors.indigo,
              icon: Icon(Icons.mic),
              label: 'Active',
            ),
            BottomNavigationBarItem(
              backgroundColor: Colors.indigo,
              icon: Icon(Icons.bluetooth),
              label: 'Bluetooth',
            ),
            BottomNavigationBarItem(
              backgroundColor: Colors.indigo,
              icon: Icon(Icons.phone_android),
              label: 'Default',
            ),
            BottomNavigationBarItem(
              backgroundColor: Colors.indigo,
              icon: Icon(Icons.headset_mic),
              label: 'Wired',
            ),
          ],
        ),
      ),
    );
  }
}
3
likes
150
points
154
downloads

Publisher

unverified uploader

Weekly Downloads

Mic Info Plugin is a Flutter plugin that retrieves information about connected microphones on Android and iOS. It supports detecting built-in, wired (including USB connector microphones), and Bluetooth microphones, making it ideal for applications requiring audio input management.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on mic_info

Packages that implement mic_info