BtStatus.fromXML constructor

BtStatus.fromXML(
  1. String xmlSTR
)

Implementation

factory BtStatus.fromXML(String xmlSTR) {
  final document = XmlDocument.parse(xmlSTR);
  String desc = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "desc",
          orElse: orElseEmpty)
      .value;
  String init = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "init")
      .value;
  String powerOff = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "powerOff")
      .value;
  String ready = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "ready")
      .value;
  String unknown = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "unknown")
      .value;
  String paperJam = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "paperJam")
      .value;
  String paperOut = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "paperOut")
      .value;
  return BtStatus(
      desc: desc,
      init: init,
      powerOff: powerOff,
      ready: ready,
      unknown: unknown,
      paperJam: paperJam,
      paperOut: paperOut);
}