TencentCloudChatMessage component offers both private messaging (1V1) and group chat features. It supports a variety of operations on messages, such as sending different types of messages, long-pressing to reply or quote messages, and querying details of read receipts.






flutter pub add tencent_cloud_chat
flutter pub add tencent_cloud_chat_message
ios/Podfile, and replace the final section with the following content.post_install do |installer|installer.pods_project.targets.each do |target|flutter_additional_ios_build_settings(target)target.build_configurations.each do |config|config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'config.build_settings['ENABLE_BITCODE'] = 'NO'config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"endtarget.build_configurations.each do |config|config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)','PERMISSION_MICROPHONE=1','PERMISSION_CAMERA=1','PERMISSION_PHOTOS=1',]endendend
TencentCloudChatMaterialApp: Replace your project's MaterialApp with TencentCloudChatMaterialApp. This enables automatic management and configurations of the language, theme *(with material3)*, theme mode, and other settings. It ensures that the UIKit's interface parameters are consistent with your project.MaterialApp with TencentCloudChatMaterialApp. This enables automatic management of global configurations, including localization, theme, and theme mode.MaterialApp due to extensive customization or the use of other packages such as Get, you can manually initialize the UIKit. This guide will help you complete the process.import 'package:tencent_cloud_chat_intl/localizations/tencent_cloud_chat_localizations.dart';
MaterialApp or another entry provided by third-party packages like GetMaterialApp.MaterialApp( localizationsDelegates: const [ /// Your configurations GlobalMaterialLocalizations.delegate, /// Add this line ...TencentCloudChatLocalizations.localizationsDelegates, /// Add this line ], supportedLocales: [ /// Your configurations ...S.delegate.supportedLocales, /// Add this line ...TencentCloudChatLocalizations.supportedLocales, ], /// ... Other configurations )
locale according to your business logic, such as recording the user-specified language upon app's launch, instead of following the system settings. This configuration will apply to both your project and the Chat UIKit.TencentCloudChatTheme class, is globally maintained and managed through TencentCloudChat.dataInstance.theme.TencentCloudChatTheme theme = TencentCloudChat.dataInstance.theme;
theme and darkTheme from MaterialApp using the Material 3 style theme data that we provide for both light and dark modes. You can also set the themeMode status based on the brightness status we maintain. This ensures a consistent appearance across your application and our Chat UIKit and enhances the user experiences. (You can customize this theme style as described below.)MaterialApp) into a StatefulWidget. Add a TencentCloudChatTheme theme as part of its state, and listen to Stream<TencentCloudChatTheme>? themeDataListener to update its value and build the app based on dynamic, and customizable theme data. Here is the sample code:// Theme instance for the Chat UIKitTencentCloudChatTheme theme = TencentCloudChat.dataInstance.theme;// Listener for theme data changesStream<TencentCloudChatTheme>? themeDataListener = TencentCloudChat.eventBusInstance.on<TencentCloudChatTheme>();// Callback for handling theme data changesvoid _themeDataChangeCallback(TencentCloudChatTheme themeData) {setState(() {theme = themeData;});}// Adds a listener for theme data changesvoid _addThemeDataChangeListener() {themeDataListener?.listen(_themeDataChangeCallback,);}@overridevoid initState() {super.initState();_addThemeDataChangeListener();}// .......return MaterialApp(themeMode: theme.brightness != null ? (theme.brightness == Brightness.light ? ThemeMode.light : ThemeMode.dark) : null,theme: theme.getThemeData(brightness: Brightness.light),darkTheme: theme.getThemeData(brightness: Brightness.dark),/// ... Other configurations);
MaterialApp as shown above), use the TencentCloudChatCoreController.setThemeColors method to specify the appearance colors for both light and dark modes. For specific usage instructions, see the comments in the code.TencentCloudChatCoreController.setBrightnessMode or TencentCloudChatCoreController.toggleBrightnessMode. For specific usage instructions, see the comments in the code.TencentCloudChat.controller.initUIKit method to initialize and log in. The call instructions and reference code are as follows:callbacks to efficiently handle SDK API errors and specific UIKit events that require user attention through Dialog or Tooltip in a customizable way.await TencentCloudChat.controller.initUIKit(config: TencentCloudChatConfig(), /// [Optional]: The global configurations that affecting the whole chat interface, including user configurations and theme configurations.options: TencentCloudChatInitOptions(sdkAppID: , /// [Required]: The SDKAppID of your Tencent Cloud chat application.userID: , /// [Required]: The userID of the logged-in user.userSig: , /// [Required]: The userSig of the logged-in user.),components: TencentCloudChatInitComponentsRelated( /// [Required]: Modular UI component settings, effective globally.usedComponentsRegister: [/// [Required]: List of registration functions for the components used in the chat interface./// Simply use the `register` from TencentCloudChatMessage.TencentCloudChatMessageManager.register,],componentConfigs: TencentCloudChatComponentConfigs(/// [Optional]: Provide custom configurations for each UI modular component here. These builders will be applied globally.),componentBuilders: TencentCloudChatComponentBuilders(/// [Optional]: Provide custom UI builders for each UI modular component here. These builders will be applied globally.),componentEventHandlers: TencentCloudChatComponentEventHandlers(/// [Optional]: Provide custom event handlers for UI component events here. These builders will be applied globally.),),/// [Critical]: It is strongly recommended to incorporate the following callback listeners for effectively managing SDK events, SDK API errors and specific UIKit events that require user attention./// For detailed usage, see the Integrating UIKit Callbacks section at the end of this README document.callbacks: TencentCloudChatCallbacks(onTencentCloudChatSDKEvent: V2TimSDKListener(), /// [Optional]: Handles SDK events, such as onKickedOffline and onUserSigExpired.onTencentCloudChatSDKFailCallback: (apiName, code, desc) {}, /// [Optional]: Handles SDK API errors.onTencentCloudChatUIKitUserNotificationEvent: (TencentCloudChatComponentsEnum component, TencentCloudChatUserNotificationEvent event) {}, /// [Optional]: Handles specific UIKit events that require user attention on a global scale.across the entire application scope.),plugins: [], /// [Optional]: Used plugins, such as tencent_cloud_chat_robot. For specific usage, see the README document of each plugin.);
TencentCloudChatMessage with the specified chat user options, you can seamlessly set up a chat module for them. This caters to both one-on-one and group chats.navigateToMessage method with TencentCloudChatMessageOptions, as shown below:final messageOptions = TencentCloudChatMessageOptions(// Provide either userID or groupID to indicate the conversation for the chat.userID: "", // For one-on-one chats, provide the other user's userID.groupID: "", // For group chats, provide the groupID.);/// Use the messageOptions constructed above.navigateToMessage(context: context, options: messageOptions);
TencentCloudChatMessage component.final messageOptions = TencentCloudChatMessageOptions(// Provide either userID or groupID to indicate the conversation for the chat.userID: "", // For one-on-one chats, provide the other user's userID.groupID: "", // For group chats, provide the groupID.);final Widget message = TencentCloudChatMessage(options: messageOptions,// ... Other parameters, such as builders, can be specified globally or passed in statically here based on your requirements. For detailed usage, see the parameter and method comments.);
build method of a separate page or use it directly for navigation like using Navigator.push.eventHandlers to manage component-specific events. This includes uiEventHandlers (such as various events like onTap) and lifeCycleEventHandlers (such as events triggered after a message has been sent).Feedback