createFileMessage static method

Future<V2TimValueCallback<V2TimMsgCreateInfoResult>> createFileMessage({
  1. required String filePath,
  2. required String fileName,
  3. dynamic inputElement,
})

Implementation

static Future<V2TimValueCallback<V2TimMsgCreateInfoResult>> createFileMessage({
  required String filePath,
  required String fileName,
  dynamic inputElement,
}) 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_FILE),
        "file_elem_file_path": filePath,
        "file_elem_file_name": fileName,
        "file_elem_file_size": 0,
      })
    ]),
  );
  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()})
  });
}