Control LED indicator lights on iMin POS devices.
Add to your pubspec.yaml:
dependencies:
imin_hardware_plugin: ^1.0.0Then run:
flutter pub getimport 'package:imin_hardware_plugin/imin_hardware_plugin.dart';The plugin exports IminLight class for LED light control.
- Connect/disconnect to light device
- Turn on green light
- Turn on red light
- Turn off lights
bool success = await IminLight.connect();bool success = await IminLight.turnOnGreen();bool success = await IminLight.turnOnRed();bool success = await IminLight.turnOff();bool success = await IminLight.disconnect();import 'package:imin_hardware_plugin/imin_hardware_plugin.dart';
class LightExample extends StatefulWidget {
@override
_LightExampleState createState() => _LightExampleState();
}
class _LightExampleState extends State<LightExample> {
bool _isConnected = false;
LightColor _currentLight = LightColor.off;
Future<void> _connect() async {
final success = await IminLight.connect();
setState(() => _isConnected = success);
}
Future<void> _turnOnGreen() async {
final success = await IminLight.turnOnGreen();
if (success) {
setState(() => _currentLight = LightColor.green);
}
}
Future<void> _turnOnRed() async {
final success = await IminLight.turnOnRed();
if (success) {
setState(() => _currentLight = LightColor.red);
}
}
Future<void> _turnOff() async {
final success = await IminLight.turnOff();
if (success) {
setState(() => _currentLight = LightColor.off);
}
}
@override
Widget build(BuildContext context) {
return Column(
children: [
Text('Connected: $_isConnected'),
Text('Current: $_currentLight'),
ElevatedButton(
onPressed: _isConnected ? null : _connect,
child: Text('Connect'),
),
ElevatedButton(
onPressed: _isConnected ? _turnOnGreen : null,
child: Text('Green Light'),
),
ElevatedButton(
onPressed: _isConnected ? _turnOnRed : null,
child: Text('Red Light'),
),
ElevatedButton(
onPressed: _isConnected ? _turnOff : null,
child: Text('Turn Off'),
),
],
);
}
}
enum LightColor { off, green, red }- Must connect to device before controlling lights
- Only one light can be active at a time
- Disconnect when done to free resources
iMin devices with LED indicator lights