tencent cloud

Chat

제품 소개
제품 개요
Basic Concepts
응용 시나리오
기능 소개
계정 시스템
사용자 정보 및 관계망
메시지 관리
그룹 시스템
Official Account
Audio/Video Call
사용 제한
구매 가이드
과금 개요
요금 안내
Purchase Instructions
Renewal Guide
연체 안내
Refund Policy
다운로드 센터
SDK & Demo 소스 코드
업데이트 로그
시나리오 솔루션
Live Streaming Setup Guide
AI Chatbot
대규모 엔터테인먼트 협업 커뮤니티
Discord 구현 가이드
IM을 게임에 통합하는 방법
WhatsApp Channel-style Official Account Integration Solution
Send Red Packet
Firewall Restrictions
클라이언트 APIs
SDK API(Web)
Android
iOS & macOS
Swift
Flutter
Electron
Unity
React Native
C APIs
C++
서버 APIs
Secure authentication with UserSig
RESTful APIs
Webhooks
콘솔 가이드
New Console Introduction
애플리케이션 생성 및 업그레이드
기본 설정
기능 설정
계정 관리
그룹 관리
Official Channel Management
콜백 설정
모니터링 대시보드
Viewing Guide for Resource Packages
Real-Time Monitor
개발 보조 툴
액세스 관리
Advanced Features
FAQ
uni-app FAQs
구매
SDK 관련 질문
계정 인증
사용자 정보 및 관계망
메시지
그룹
라이브 방송 그룹
닉네임 및 프로필 사진
협약 및 인증
Service Level Agreement
컴플라이언스 인증
IM 정책
개인 정보 보호 정책
데이터 개인 정보 보호 및 보안 계약
에러 코드
문의하기

Flutter

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-07-15 11:48:06

Plugin Feature

From version 5.1.5 of tencent_cloud_chat_sdk onwards, you can integrate the vote plugin tencent_cloud_chat_vote_plugin provided by Tencent Cloud Instant Messaging. It is a closed-source plugin. After this plugin is integrated, you can integrate the vote feature into groups (except Community and AVChatRoom) to initiate (single-choice and multiple-choice) a vote, view vote results, and participate in a vote. The vote feature is interoperable between Flutter and Native.

Environment and Version

This plugin depends on other plugins and environments.
Flutter 3.10.0 or later
tencent_cloud_chat_sdk 5.1.5 or later

Plugin Introduction

You can introduce the vote plugin tencent_cloud_chat_vote_plugin 1.0.2 into a project via pub:
// Integrate the latest version.
pub add tencent_cloud_chat_vote_plugin
// Integrate a specific version by adding it to the dependencies field in the project's pubspec.yaml.
tencent_cloud_chat_vote_plugin: "version"

Plugin Integration

Initializing the Plugin

// Place after logging into IM.

await TencentCloudChatVotePlugin.initPlugin();

Creating a Vote

Users can create a vote by clicking the Vote button.
import 'package:example/config.dart';
import 'package:flutter/material.dart';
import 'package:tencent_cloud_chat_vote_plugin/components/vote_create/vote_create.dart';

class VoteCreateExample extends StatefulWidget {
const VoteCreateExample({super.key});

@override
State<StatefulWidget> createState() => VoteCreateExampleState();
}

class VoteCreateExampleState extends State {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Creating a Vote")
),
body: Container(
padding: const EdgeInsets.all(16),
child: TencentCloudChatVoteCreate(
groupID: ExampleConfig.testGruopID,
onCreateVoteSuccess: () {
Navigator.pop(context);
},
),
),
);
}
}
TencentCloudChatVoteCreate Parameter Description
Parameter
Description
groupID
The ID of the group for vote creation, the same as the IM group ID (except for Community and AVChatRoom).
onCreateVoteSuccess
Callback for successful vote creation.

Parsing Vote Messages

import 'package:example/config.dart';
import 'package:example/vote_detail_example.dart';
import 'package:flutter/material.dart';
import 'package:tencent_cloud_chat_sdk/enum/history_msg_get_type_enum.dart';
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
import 'package:tencent_cloud_chat_vote_plugin/tencent_cloud_chat_vote_plugin.dart';

class VoteMessageExample extends StatefulWidget {
const VoteMessageExample({super.key});

@override
State<StatefulWidget> createState() => VoteMessageExampleState();
}

class VoteMessageExampleState extends State {
V2TimMessage? message;
getTestV2TimMessage() async {
V2TimValueCallback<List<V2TimMessage>> messageListRes =
await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.getHistoryMessageList(
count: 1,
groupID: ExampleConfig.testGruopID,
getType: HistoryMsgGetTypeEnum.V2TIM_GET_CLOUD_OLDER_MSG,
);
if (messageListRes.code == 0) {
if (messageListRes.data != null) {
if (messageListRes.data!.isNotEmpty) {
setState(() {
message = messageListRes.data!.first;
});
}
}
}
}

bool isEnd = false;
@override
void initState() {
super.initState();
Future.delayed(
const Duration(
milliseconds: 300,
), () {
setState(() {
isEnd = true;
});
});
// Show component after page animation ends.
getTestV2TimMessage();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Vote Message Body"),
),
body: !isEnd
? Container()
: message != null
? TencentCloudChatVoteMessage(
message: message!,
onTap: (
TencentCloudChatVoteDataOptoin option,
TencentCloudChatVoteLogic data,
) {
print(data.voteData.toJson());
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => VoteDetailExample(
option: option,
data: data,
),
),
);
},
)
: const Center(
child: Text("Failed to get a valid Message instance."),
),
);
}
}

TencentCloudChatVoteMessage Parameter Description
Parameter
Description
message
Vote message of V2TimMessage type.
onTap
Click the vote callback. You can check group vote details in case of a public and real-name vote.

Viewing Vote Details

import 'package:flutter/material.dart';
import 'package:tencent_cloud_chat_vote_plugin/tencent_cloud_chat_vote_plugin.dart';

class VoteDetailExample extends StatelessWidget {
final TencentCloudChatVoteDataOptoin option;
final TencentCloudChatVoteLogic data;
const VoteDetailExample({
super.key,
required this.option,
required this.data,
});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(option.option),
),
body: Padding(
padding: const EdgeInsets.all(16),
child: TencentCloudChatVoteDetail(
option: option,
data: data,
),
),
);
}
}

TencentCloudChatVoteDetail Parameter Description
Parameter
Description
option
TencentCloudChatVoteDataOption type. Vote details data, obtained when TencentCloudChatVoteMessage is clicked.
data
TencentCloudChatVoteLogic type, obtained when TencentCloudChatVoteMessage is clicked.



도움말 및 지원

문제 해결에 도움이 되었나요?

피드백