startDiscovery static method

dynamic startDiscovery(
  1. dynamic callback(
    1. Map discoveryType,
    2. List deviceList
    )
)

Implementation

static startDiscovery(callback(Map discoveryType, List deviceList)) async {
  if (AliIotPlugin.debug) {
    print("$TAG : startDiscovery");
  }
  _startDiscoverySubscription = AliIotPlugin.eventChannel.receiveBroadcastStream("startDiscovery").listen((event) {
    if (event != null) {
      print("$TAG : startDiscovery event: " + event.toString());
      if (event is Map<String, dynamic>) {
        var data = jsonDecode(event["data"]);
        callback(data["discoveryType"], data["deviceList"]);
      }
    }
  });
  AliIotPlugin.methodChannel.invokeMethod('startDiscovery');
}