broadCastStatus method

void broadCastStatus(
  1. Function? listener
)

Implementation

void broadCastStatus(Function? listener) {
  channel.invokeMethod('checkPrinterStatus').then((v){

    try{
      final status = ZebraPrinterStatus.fromJson(jsonDecode(v));
      listener?.call(status);
      Future.delayed(const Duration(seconds: 1),(){
        broadCastStatus(listener);
      });
    }catch(e){
      Future.delayed(const Duration(seconds: 5),(){
        broadCastStatus(listener);
      });
    }
  });
}