handleMethodCall method

Future handleMethodCall(
  1. MethodCall call
)

Implementation

Future<dynamic> handleMethodCall(MethodCall call) async {
  switch (call.method) {
    case "getValueForCharacteristic":
      var characteristic = findCharacteristic(
        peripheral: call.arguments['peripheral'],
        uuid: call.arguments['uuid']
      );
      if (characteristic?.valueProducer == null) {
        return null;
      }
      return await characteristic!.valueProducer!();
    case "setValueForCharacteristic":
      final characteristic = findCharacteristic(
        peripheral: call.arguments["peripheral"],
        uuid: call.arguments["uuid"],
      );
      final valueHandler = characteristic?.valueHandler;
      if (valueHandler != null) {
        valueHandler(call.arguments["value"]);
      }
      return null;
    case "getValueForDescriptor":
      var descriptor = findDescriptor(
        peripheral: call.arguments['peripheral'],
        uuid: call.arguments['uuid']
      );
      if (descriptor?.valueProducer == null) {
        return null;
      }
      return await descriptor!.valueProducer!();
    case "setValueForDescriptor":
      final descriptor = findDescriptor(
        peripheral: call.arguments['peripheral'],
        uuid: call.arguments['uuid']
      );
      final valueHandler = descriptor?.valueHandler;
      if (valueHandler != null) {
        valueHandler(call.arguments["value"]);
      }
      return null;
    default:
      return null;
  }
}