createMessage method Null safety

Future createMessage(
  1. {required JMMessageType? type,
  2. required dynamic targetType,
  3. String? text,
  4. String? path,
  5. String? fileName,
  6. Map? customObject,
  7. double? latitude,
  8. double? longitude,
  9. int? scale,
  10. String? address,
  11. Map? extras}
)

Implementation

Future<dynamic> createMessage({
  required JMMessageType? type, // 消息类型
  required dynamic targetType,

  /// (JMSingle | JMGroup | JMChatRoom)
  String? text,
  String? path,
  String? fileName,
  Map<dynamic, dynamic>? customObject,
  double? latitude,
  double? longitude,
  int? scale,
  String? address,
  Map<dynamic, dynamic>? extras,
}) async {
  Map param = targetType.toJson();

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

  param
    ..addAll({
      'messageType': getStringFromEnum(type),
      'text': text,
      'path': path,
      'fileName': fileName,
      'customObject': customObject,
      'latitude': latitude,
      'longitude': longitude,
      'scale': scale,
      'address': address,
    });

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