getPrinterStatus method
Requests the current printer status from the native layer.
This method calls a native function that returns an integer status code. The integer code is then mapped into a human-readable status message.
Implementation
@override
Future<String> getPrinterStatus() async {
try {
final code = await _channel.invokeMethod<int>('printStatus') ?? -1;
switch (code) {
case 0:
return "Normal";
case 1:
return "Head opened";
case 2:
return "Paper Jam";
case 3:
return "Paper Jam and head opened";
case 4:
return "Out of paper";
case 5:
return "Out of paper and head opened";
case 8:
return "Out of ribbon";
case 9:
return "Out of ribbon and head opened";
case 10:
return "Out of ribbon and paper jam";
case 11:
return "Out of ribbon, paper jam and head opened";
case 12:
return "Out of ribbon and out of paper";
case 13:
return "Out of ribbon, out of paper and head opened";
case 16:
return "Pause";
case 32:
return "Printing";
default:
return "Other error ($code)";
}
} catch (e) {
return "Error: $e";
}
}