Thanks to visit codestin.com
Credit goes to github.com

Skip to content

hans007/chat-demo-flutter

 
 

Repository files navigation

Tencent Chat Logo

Tencent Cloud Chat Demo


Globally interconnected In-App Chat, user profile and relationship chains and offline push.


More languages: 简体中文 한국어 日本語


Environment Requirements

Version
Flutter Flutter 2.2.0 or later for the IM SDK; Flutter 2.10.0 or later for the TUIKit integration component library.
Android Android Studio 3.5 or later; devices with Android 4.1 or later for apps
iOS Xcode 11.0 or later. Ensure that your project has a valid developer signature.

Preparation

  1. You have signed up for a Tencent Cloud account and completed identity verification.
  2. You have created an application as instructed in Creating and Upgrading an Application and recorded the SDKAppID.

Running the demo

  1. Download the source code and install dependencies:
# Clone the code
git clone https://github.com/TencentCloud/tc-chat-demo-flutter.git

# Install dependencies
flutter pub get
  1. Run the demo:
# Start the demo. Replace `SDK_APPID` and `KEY`
flutter run --dart-define=SDK_APPID={YOUR_SDKAPPID} --dart-define=ISPRODUCT_ENV=false --dart-define=KEY={YOUR_KEY}
  • --dart-define=SDK_APPID={YOUR_SDKAPPID}. Here, {YOUR_SDKAPPID} needs to be replaced with the SDKAppID of your application.
  • --dart-define=ISPRODUCT_ENV=false. Set it to false for a development environment.
  • --dart-define=KEY={YOUR_KEY}. Here, {YOUR_KEY} needs to be replaced with the Key recorded in Part 1. Creating a Test User.

(Optional) Using the IDE

Android

  1. Go to the discuss/android directory via Android Studio.

  1. Start an Android simulator, tap Build And Run to run the demo. Enter a random UserID (a combination of digits and letters).

The UI of the latest version of the demo may look different after adjustments.

iOS

  1. Open Xcode and the file discuss/ios/Runner.xcodeproj:

  1. Connect an iPhone, and click Build And Run. After the iOS project is built, the Xcode project will be displayed in a new pop-up window.

  2. Open the iOS project, and set Signing & Capabilities (an iPhone developer account required) for the primary target to run the project on the iPhone.

  3. Start the project and debug the demo on the iPhone device.

Demo code structure

The TUIKit for Flutter is used for the UI and business logic of the demo. The demo layer itself is only used to build the application, process navigation redirects, and call instantiated TUIKit components.

Folder Description
lib Core application directory
lib/i18n Internationalization code, excluding the internationalization capabilities and strings of TUIKit, which can be imported as needed.
lib/src Main application directory
lib/src/pages Important navigation pages of the demo. After the application is initialized, app.dart displays the loading animation, judges the login status, and redirects the user to login.dart or home_page.dart. After the user logs in, the login information will be stored locally through the shared_preference plugin and used for automatic login upon future application launch. If there is no such information or the login fails, the user will be redirected to the login page. During automatic login, the user is still on app.dart and can see the loading animation. home_page.dart has a bottom tab to switch between the four main feature pages of the demo.
lib/utils Some tool function classes.

Basically, a TUIKit component is imported into each dart file in lib/src. After the component is instantiated in the file, the page can be rendered.

Below are main files:

Main File in lib/src Description
add_friend.dart Friend request page that uses the TIMUIKitAddFriend component.
add_group.dart Group joining request page that uses the TIMUIKitAddGroup component.
blacklist.dart Blocklist page that uses the TIMUIKitBlackList component.
chat.dart Main chat page that uses all the chat capabilities of TUIKit and the TIMUIKitChat component.
chatv2.dart Main chat page that uses atomic capabilities and the TIMUIKitChat component.
contact.dart Contacts page that uses the TIMUIKitContact component.
conversation.dart Conversation list page that uses the TIMUIKitConversation component.
create_group.dart Group chat page that is implemented in the demo with no component used.
group_application_list.dart Group application list page that uses the TIMUIKitGroupApplicationList component.
group_list.dart Group list page that uses the TIMUIKitGroup component.
group_profile.dart Group profile and management page that uses the TIMUIKitGroupProfile component.
newContact.dart New contact request page that uses the TIMUIKitNewContact component.
routes.dart Demo route that navigates users to the login page login.dart or homepage home_page.dart.
search.dart Global search and in-conversation search page that uses the TIMUIKitSearch (global search) and TIMUIKitSearchMsgDetail (in-conversation search) components.
user_profile.dart User information and relationship chain maintenance page that uses the TIMUIKitProfile component.

The navigation redirect method needs to be imported into most TUIKit components; therefore, the demo layer needs to process Navigator.

You can modify the above demo for secondary development or implement your business needs based on it.

About

腾讯云即时通信IM Flutter Demo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 94.1%
  • Dart 5.7%
  • HTML 0.1%
  • Ruby 0.1%
  • CSS 0.0%
  • Swift 0.0%