send method Null safety

Future<void> send(
  1. String code
)

send(code);

Send IRCC code to TV. IRCC code is for a remote control button (like play/pause/etc.)

Implementation

Future<void> send(String code) async {
  final codes = await getIRCCCodes();
  final ircc = codes.firstWhere((c) => mangle(c['name']) == mangle(code));
  if (ircc == null) {
    print('IRCC code $code unknown');
    return;
  }
  final body = '''<?xml version="1.0"?>
        <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <s:Body>
                <u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1">
                    <IRCCCode>$ircc</IRCCCode>
                </u:X_SendIRCC>
            </s:Body>
        </s:Envelope>''';

  await request('/IRCC', body);
}