perfect_volume_control 1.0.5 copy "perfect_volume_control: ^1.0.5" to clipboard
perfect_volume_control: ^1.0.5 copied to clipboard

Flutter volume control plug-in, supports Android and IOS, has: Show hidden volume icon, volume change monitoring, set volume, get the current volume of the device.

example/lib/main.dart

import 'dart:async';

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

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  TextEditingController _textEditingController = TextEditingController();

  StreamSubscription<double> _subscription;

  @override
  void initState() {
    super.initState();
    // Bind listener
    _subscription = PerfectVolumeControl.stream.listen((value) {
      _textEditingController.text = "listener: $value";
    });
  }

  @override
  void dispose() {
    super.dispose();

    // Remove listener
    _subscription.cancel();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: SafeArea(
          child: Padding(
            padding: const EdgeInsets.all(20.0),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                TextField(controller: _textEditingController),
                Container(height: 10),
                Center(
                  child: Wrap(
                    spacing: 10,
                    runSpacing: 10,
                    children: [
                      OutlinedButton(
                        child: Text("hideUI"),
                        onPressed: () async {
                          PerfectVolumeControl.hideUI = true;
                          _textEditingController.text = "hideUI finish";
                        },
                      ),
                      OutlinedButton(
                        child: Text("showUI"),
                        onPressed: () async {
                          PerfectVolumeControl.hideUI = false;
                          _textEditingController.text = "showUI finish";
                        },
                      ),
                      OutlinedButton(
                        child: Text("getVolume"),
                        onPressed: () async {
                          double volume =
                              await PerfectVolumeControl.getVolume();
                          _textEditingController.text = "$volume";
                        },
                      ),
                      OutlinedButton(
                        child: Text("mute"),
                        onPressed: () async {
                          await PerfectVolumeControl.setVolume(0);
                          _textEditingController.text = "mute finish";
                        },
                      ),
                      OutlinedButton(
                        child: Text("setVolume to 0.3"),
                        onPressed: () async {
                          await PerfectVolumeControl.setVolume(0.3);
                          _textEditingController.text =
                              "setVolume to 0.3 finish";
                        },
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
33
likes
130
pub points
92%
popularity

Publisher

verified publisherhuic.top

Flutter volume control plug-in, supports Android and IOS, has: Show hidden volume icon, volume change monitoring, set volume, get the current volume of the device.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on perfect_volume_control