nativeMethodCallHandler method

Future<void> nativeMethodCallHandler(
  1. MethodCall methodCall
)

Implementation

Future<void> nativeMethodCallHandler(MethodCall methodCall) async {
  if (methodCall.method == "printerFound") {
    final newPrinter = ZebraDevice(
      address: methodCall.arguments["Address"],
      status: methodCall.arguments["Status"],
      name: methodCall.arguments["Name"],
      isWifi: methodCall.arguments["IsWifi"] == "true",
    );
    controller.addPrinter(newPrinter);
  } else if (methodCall.method == "printerRemoved") {
    final String address = methodCall.arguments["Address"];
    controller.removePrinter(address);
  } else if (methodCall.method == "changePrinterStatus") {
    final String status = methodCall.arguments["Status"];
    final String color = methodCall.arguments["Color"];
    controller.updatePrinterStatus(status, color);
  } else if (methodCall.method == "onDiscoveryError" &&
      onDiscoveryError != null) {
    onDiscoveryError!(
        methodCall.arguments["ErrorCode"], methodCall.arguments["ErrorText"]);
  } else if (methodCall.method == "onDiscoveryDone") {
    if (shouldSync) {
      _getLocateValue(key: "connected").then((connectedString) {
        controller.synchronizePrinter(connectedString);
        shouldSync = false;
      });
    }
  }
}