headsetevent_fix 0.0.1 icon indicating copy to clipboard operation
headsetevent_fix: ^0.0.1 copied to clipboard

Detect headset plugged, unplugged.

example/lib/main.dart

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

// void main() => runApp(MyApp());

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

// class _MyAppState extends State<MyApp> {
//   HeadsetEvent headsetPlugin = new HeadsetEvent();
//   HeadsetState headsetEvent;

//   @override
//   void initState() {
//     super.initState();

//     /// if headset is plugged
//     headsetPlugin.getCurrentState.then((_val){
//       setState(() {
//         headsetEvent = _val;
//       });
//     });

//     /// Detect the moment headset is plugged or unplugged
//     headsetPlugin.setListener((_val) {
//       setState(() {
//         headsetEvent = _val;
//       });
//     });
//   }

//   @override
//   Widget build(BuildContext context) {
//     return MaterialApp(
//       home: Scaffold(
//         appBar: AppBar(
//           title: const Text('Headset Event Plugin'),
//         ),
//         body: Center(
//           child:Column(
//           mainAxisAlignment: MainAxisAlignment.center,
//           children: <Widget>[
//             Icon(Icons.headset, color: this.headsetEvent == HeadsetState.CONNECT ? Colors.green : Colors.red,),
//             Text('State : $headsetEvent\n'),
//           ],
//         )),
//       ),
//     );
//   }
// }
0
likes
90
pub points
0%
popularity

Publisher

unverified uploader

Detect headset plugged, unplugged.

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.BSD-3-Clause (LICENSE)

Dependencies

flutter, meta

More

Packages that depend on headsetevent_fix