tello static method

Future<Tello> tello({
  1. Duration? timeout = const Duration(seconds: 12),
  2. Address? telloAddress,
  3. Address? localAddress,
  4. Address? stateReceiverAddress,
})

Serves as the constructor for the Tello class, is a static method because constructors can't be asynchronous.

Implementation

static Future<Tello> tello({
  Duration? timeout = const Duration(seconds: 12),
  Address? telloAddress,
  Address? localAddress,
  Address? stateReceiverAddress,
}) async {
  stateReceiverAddress = stateReceiverAddress ??
      Address(ip: InternetAddress.anyIPv4, port: 8890);

  List<TelloSocket> sockets = await Future.wait([
    TelloSocket.telloSocket(
        telloAddress: telloAddress,
        localAddress: localAddress,
        timeout: timeout),
    TelloSocket.telloSocket(
        telloAddress: telloAddress,
        localAddress: stateReceiverAddress,
        timeout: timeout)
  ]);

  Tello tello = Tello._(sockets[0], sockets[1]);

  await tello._command("command");

  return tello;
}