createLocationMessage static method

Future<V2TimValueCallback<V2TimMsgCreateInfoResult>> createLocationMessage({
  1. required String desc,
  2. required double longitude,
  3. required double latitude,
})

Implementation

static Future<V2TimValueCallback<V2TimMsgCreateInfoResult>> createLocationMessage({
  required String desc,
  required double longitude,
  required double latitude,
}) async {
  Map<String, dynamic> message = Tools.createNativeMessage(
    elem: List<Map<String, dynamic>>.from([
      Map<String, dynamic>.from({
        "elem_type": Tools.dartElemTypeToNative(MessageElemType.V2TIM_ELEM_TYPE_LOCATION),
        "location_elem_desc": desc,
        "location_elem_longitude": longitude,
        "location_elem_latitude": latitude,
      })
    ]),
  );
  String key = Tools.generateUniqueString();
  createdMessage[key] = message;

  return V2TimValueCallback<V2TimMsgCreateInfoResult>.fromJson({
    "code": 0,
    "desc": "success",
    "data": Map<String, dynamic>.from({"id": key, "messageInfo": (await Tools.convertMessage2Dart(message)).toJson()})
  });
}