mirror of
https://github.com/TencentCloud/TIMSDK.git
synced 2026-10-22 01:06:31 +08:00
91 lines
2.6 KiB
Dart
91 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:im_api_example/im/conversationSelector.dart';
|
|
import 'package:im_api_example/im/messageSelector.dart';
|
|
import 'package:im_api_example/utils/sdkResponse.dart';
|
|
import 'package:tencent_im_sdk_plugin/models/v2_tim_callback.dart';
|
|
import 'package:tencent_im_sdk_plugin/tencent_im_sdk_plugin.dart';
|
|
import 'package:im_api_example/i18n/i18n_utils.dart';
|
|
|
|
class DeleteMessageFromLocalStorage extends StatefulWidget {
|
|
@override
|
|
State<StatefulWidget> createState() => DeleteMessageFromLocalStorageState();
|
|
}
|
|
|
|
class DeleteMessageFromLocalStorageState
|
|
extends State<DeleteMessageFromLocalStorage> {
|
|
Map<String, dynamic>? resData;
|
|
|
|
List<String> conversaions = List.empty(growable: true);
|
|
List<String> msgIDs = List.empty(growable: true);
|
|
deleteMessageFromLocalStorage() async {
|
|
V2TimCallback res = await TencentImSDKPlugin.v2TIMManager
|
|
.getMessageManager()
|
|
.deleteMessageFromLocalStorage(
|
|
msgID: msgIDs.first,
|
|
);
|
|
setState(() {
|
|
resData = res.toJson();
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
child: Column(
|
|
children: [
|
|
new Row(
|
|
children: [
|
|
ConversationSelector(
|
|
onSelect: (data) {
|
|
setState(() {
|
|
conversaions = data;
|
|
});
|
|
},
|
|
switchSelectType: true,
|
|
value: conversaions,
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(left: 10),
|
|
child: Text(conversaions.length > 0
|
|
? conversaions.toString()
|
|
: imt("未选择")),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
MessageSelector(
|
|
conversaions.isNotEmpty ? conversaions.first : "",
|
|
msgIDs,
|
|
(data) {
|
|
setState(() {
|
|
msgIDs = data;
|
|
});
|
|
},
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(left: 12),
|
|
child: Text(msgIDs.toString()),
|
|
))
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: ElevatedButton(
|
|
onPressed: deleteMessageFromLocalStorage,
|
|
child: Text(imt("删除本地消息")),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
SDKResponse(resData),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|