sendCustomMessage method Null safety

Future<JMCustomMessage> sendCustomMessage(
  1. {required dynamic type,
  2. required Map? customObject,
  3. JMMessageSendOptions? sendOption,
  4. Map? extras}
)

Implementation

Future<JMCustomMessage> sendCustomMessage({
  required dynamic type,

  /// (JMSingle | JMGroup | JMChatRoom)
  required Map<dynamic, dynamic>? customObject,
  JMMessageSendOptions? sendOption,
  Map<dynamic, dynamic>? extras,
}) async {
  Map param = type.toJson();

  Map optionMap = {};
  if (sendOption != null) {
    optionMap = {
      'messageSendingOptions': sendOption.toJson()
        ..removeWhere((key, value) => value == null)
    };
  }

  if (extras != null) {
    param..addAll({'extras': extras});
  }

  param..addAll(optionMap)..addAll({'customObject': customObject});

  Map resMap = await _channel.invokeMethod(
      'sendCustomMessage', param..removeWhere((key, value) => value == null));
  var res = JMNormalMessage.generateMessageFromJson(resMap);
  return res;
}