sendLocationMessage method Null safety

Future<JMLocationMessage> sendLocationMessage(
  1. {@required dynamic type,
  2. @required double? latitude,
  3. @required double? longitude,
  4. @required int? scale,
  5. String? address,
  6. JMMessageSendOptions? sendOption,
  7. Map? extras}
)

Implementation

Future<JMLocationMessage> sendLocationMessage({
  @required dynamic type,

  /// (JMSingle | JMGroup | JMChatRoom)
  @required double? latitude,
  @required double? longitude,
  @required int? scale,
  String? address,
  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({
      'latitude': latitude,
      'longitude': longitude,
      'scale': scale,
      'address': address,
    });

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