tencent cloud

Chat

News and Announcements
Release Notes
Announcements
Product Introduction
Overview
Basic Concepts
Scenarios
Features
Account System
User Profile and Relationship Chain
Message Management
Group Related
Official Account
Audio/Video Call
Use Limits
Purchase Guide
Billing Overview
Pricing
Purchase Instructions
Renewal Guide
Service Suspension Explanation
Refund Policy
Development Guidelines
Demo Zone
Activate Service
Free Demos
Quick Run
Download
SDK and Demo Source Code
Update Log
Chat Interaction (UI Included)
TUIKit Introduction
Getting Started
Full-feature Integration
Single-function Integration
Build with AI
Build Basic Interfaces
More Features
Customizing Appearance
Internationalization
Push Service
Overview
Noun explanation
Activate the Service
Quick Start
Manufacturer Channel
Statistics
Troubleshooting Tool
Client APIs
REST API
Push Callback
Advanced Features
Release Notes
Error Codes
FAQS
Desk
Overview
Quick Start
Integration Guide
Admin Operation Manual
Agent Manual
More Practices
Live Streaming Setup Guide
AI Chatbot
Super Large Entertainment and Collaboration Community
Discord Implementation Guide
How to Integrate Chat into Games
WhatsApp Channel-style Official Account Integration Solution
Send Red Packet
Firewall Restrictions
No UI Integration
Quick Start
SDK Integration
Initialization
Login and Logout
Message
Conversation
Group
Community Topic
User Profile and Relationship Chain
Offline Push
Cloud Search
Local Search
Official Channel Management
Client APIs
JavaScript
Android
iOS & macOS
Swift
Flutter
Electron
Unity
React Native
C APIs
C++
Server APIs
Secure authentication with UserSig
RESTful APIs
Webhooks
Console Guide
New Console Introduction
Creating and Upgrading an Application
Basic Configuration
Feature Configuration
Account Management
Group Management
Official Channel Management
Webhook Configuration
Usage
Viewing Guide for Resource Packages
Real-Time Monitor
Auxiliary Development Tools
Access Management
Advanced Features
FAQs
uni-app FAQs
Purchase
SDK
Account Authentication
User Profile and Relationship Chain
Message
Group
Audio-Video Group
Nickname and Profile Photo
Security Compliance Certification
Service Level Agreement
Security Compliance Certification
Chat Policies
Privacy Policy
Data Privacy and Security Agreement
Migration
Migration Solutions
Migration Solutions Lite
Error Codes
Contact Us

Flutter

PDF
Focus Mode
Font Size
Last updated: 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.



Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback