createFileMessage method

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

创建文件消息

参数: filePath 文件路径 fileName文件名称 inputElement 用于选择文件的 DOM 节点(web端使用,且必填)

Implementation

Future<V2TimValueCallback<V2TimMsgCreateInfoResult>> createFileMessage({
  required String filePath,
  required String fileName,
  dynamic inputElement,
}) async {
  if (await pathExits(filePath)) {
    return ImFlutterPlatform.instance.createFileMessage(
      filePath: filePath,
      fileName: fileName,
      inputElement: inputElement,
    );
  }
  return V2TimValueCallback<V2TimMsgCreateInfoResult>.fromJson({
    "code": -5,
    "desc": "filePath is not found",
    "data": V2TimMsgCreateInfoResult.fromJson(
      {
        "id": "",
        "messageInfo": V2TimMessage(
          elemType: 0,
        ),
      },
    ),
  });
}