Nexconn Flutter Chat UI Kit Tutorial: Build Real-Time Messaging in 10 Minutes

Nexconn Flutter Chat UI Kit Tutorial: Build Real-Time Messaging in 10 Minutes
Ryan Yang
Ryan Yang
Nexconn Infrastructure Engineer. Optimizes latency and scales microservices for hundreds of millions of concurrent users. Shares technical deep dives and backend lessons for zero-latency communication.

Building real-time messaging from scratch means handling connection lifecycles, offline synchronization, state management, and push notification edge cases. Most engineering teams prefer using a dedicated SDK so they can focus on their core product.

📺 Prefer a visual walkthrough? Watch the complete step-by-step video guide on YouTube to see the integration in action.

This guide walks you through integrating the Nexconn Flutter Chat SDK into a Flutter app from scratch. By following these steps, you will set up authentication, initialize the client, connect to the messaging cluster, and render a working conversation UI in about ten minutes.


What We Are Building

We will integrate the Nexconn Chat Flutter SDK and prebuilt UI components to achieve:

  1. Client initialization with data center routing.
  2. User authentication via token-based connection.
  3. A functional channel list and conversation screen capable of sending real-time messages.
Developer Note: Nexconn provides a production-ready Chat Pro plan free up to 10,000 MAU (normally $860/month). To lock in this tier through 2027, you only need to integrate and use the Nexconn Chat SDK in your project.

Prerequisites

Before writing code, make sure you have:

  • Ensure your development environment meets the following specifications:
  • Flutter SDK: 3.29.2 or later (required by Chat UI Kit).
  • Dart SDK: Compatible with 3.9.2+ (Note: the core Chat SDK requires Dart ^3.7.2, but the prebuilt UI plugin requires Dart 3.9.2+).
  • A registered account on the Nexconn Developer Console.
  • An iOS Simulator or Android Emulator.

Step 1: Create an App and Retrieve Your Credentials

To connect to Nexconn, you need an App Key for client configuration and a temporary User Token for authentication.

  1. Log into the Nexconn Console. A default application is created automatically upon registration.
  2. Under Chat Subscription, ensure the Chat Pro 10K promotional tier is selected.
  3. In the application settings or dashboard, copy your App Key (default data center is set to Singapore).
  4. Go to Application Information / App Key, scroll down to token testing, enter a test User ID (e.g., user_001), and click Get Token. Copy this token string for local testing.

Step 2: Add Dependencies to Your Flutter Project

Add both the Chat UI plugin and the core Chat plugin to your Flutter project:

flutter pub add ai_nexconn_chatui_plugin ai_nexconn_chat_plugin

Alternatively, declare them inside your pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter
  ai_nexconn_chat_plugin: ^26.2.11
  ai_nexconn_chatui_plugin: ^26.2.11

Run flutter pub get.

Platform Configuration

  • Android: Open android/app/build.gradle. Ensure minSdkVersion is set to 21 or higher.
  • iOS: Open ios/Podfile. Ensure the deployment target is set to iOS 12.0 or higher:
platform :ios, '12.0'

Step 3: Initialize the Nexconn Engine

Because the prebuilt UI widgets depend on EngineProvider across the widget tree, you must instantiate EngineProvider and wrap your app with NexconnChatUIProviders inside main():

import 'package:flutter/material.dart';
import 'package:ai_nexconn_chatui_plugin/ai_nexconn_chatui_plugin.dart';
import 'package:ai_nexconn_chat_plugin/ai_nexconn_chat_plugin.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  const String appKey = 'YOUR_APP_KEY_HERE';

  final initParams = InitParams(
    appKey: appKey,
    areaCode: AreaCode.SG, // Default Singapore data center
  );

  // 1. Instantiate and initialize EngineProvider
  final engineProvider = EngineProvider();
  await engineProvider.initialize(initParams);

  // 2. Wrap your application with NexconnChatUIProviders
  runApp(
    NexconnChatUIProviders(
      engineProvider: engineProvider,
      child: const MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: ChatHomeScreen(),
    );
  }
}

Step 4: Authenticate and Establish Connection

In production, your client app queries your backend server to receive a signed user token. For this quickstart, use the token generated in the console during Step 1.

Call NCEngine.connect() to open the persistent socket connection:

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

  @override
  State<ChatHomeScreen> createState() => _ChatHomeScreenState();
}

class _ChatHomeScreenState extends State<ChatHomeScreen> {
  bool _isConnected = false;
  String _statusText = 'Disconnected';

  @override
  void initState() {
    super.initState();
    _connect();
  }

  Future<void> _connect() async {
    const String testToken = 'YOUR_TEST_TOKEN_FROM_CONSOLE';
    final connectParams = ConnectParams(token: testToken);

    // Read the EngineProvider initialized in main() from the widget tree.
    final engineProvider = context.read<EngineProvider>();

    // Use the standard single-callback handler to process the connection result.
    await engineProvider.connect(
      connectParams,
      handler: (String? userId, NCError? error) {
        // On success, the SDK returns a userId together with NCError(code: 0),
        // so check error?.isSuccess instead of error == null.
        if (error?.isSuccess == true && userId != null) {
          setState(() {
            _isConnected = true;
            _statusText = 'Connected as: $userId';
          });
          debugPrint('Connected successfully as: $userId');
        } else {
          setState(() {
            _statusText = 'Connection failed: ${error?.message ?? 'Unknown error'}';
          });
          debugPrint('Connection error: ${error?.code} - ${error?.message}');
        }
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Nexconn Chat Demo')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(_statusText),
            const SizedBox(height: 24),
            ElevatedButton(
              onPressed: _isConnected ? _navigateToChannelPage : null,
              child: const Text('Open Conversation Screen'),
            ),
          ],
        ),
      ),
    );
  }

  void _navigateToChannelPage() {
    Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) => const ChannelPage(),
      ),
    );
  }
}

Step 5: Run the App and Send Your First Message

Start your application on an emulator or connected device:

flutter run

Then verify the flow:

  1. The connection status should update to Connected as: user_001.
  2. Tap Open Conversation Screen to mount the default prebuilt ChannelPage.
  3. If the channel list is empty (expected for a brand-new test user), create a direct channel from another test account to user_001, or mount ChannelPage with an initialChannels list.
  4. Open the channel, type a message or send an emoji, and press Send.

Production Architecture Considerations

Before deploying this to production, keep these operational requirements in mind:

  1. Keep Secrets on Your Backend: Never bundle your App Secret inside client-side Flutter code. Your backend must call Nexconn's REST API using the secret to generate user tokens, returning only the token to the authenticated mobile user.
  2. Handle Multi-Channel Push: For background notifications on iOS and Android when the app is suspended, configure APNs certificates and Firebase Cloud Messaging (FCM) credentials in the Nexconn console.
  3. Network Resilience: The SDK includes automatic reconnection and offline delta sync. When network connectivity drops, messages queue locally and synchronize once the socket re-establishes.

Next Steps

You now have a fully functional real-time chat pipeline operating inside your Flutter application.

  • Explore advanced messaging features in the Nexconn Flutter Documentation.
  • Add rich media attachments, typing indicators, and read receipts.
  • Set up webhooks on your server to sync messaging events with your CRM or moderation pipeline.
Contact us
Contact us
We'd love to discuss how Nexconn's real-time communication solutions can support your business. Request a demo, explore pricing, or get tailored onboarding guidance.

Related Articles

How to Build In-App Chat in Next.js (App Router) with Nexconn

How to Build In-App Chat in Next.js (App Router) with Nexconn

Home > Blog > Next.js Chat Tutorial Everything runs on Nexconn's Free Chat Plan (up to 10,000 MAU, no credit card required), so you can follow along without a budget conversation. The ticket sounds harmless: let buyers message sellers before they check out. Your Next.js app already has sign-in, listings and a checkout flow, so how hard can chat be? Then the real questions show up. Who is allowed to open a connection, and how do you prove it without putting a secret in the browser?

Build a Real-Time Flutter Chat App for Free (2026 Tutorial)

Build a Real-Time Flutter Chat App for Free (2026 Tutorial)

Home > Blog > Build a Flutter Chat App for Free Flutter makes it possible to build one product experience for iOS and Android, but a reliable chat feature still needs more than a message list and a WebSocket connection. Mobile networks change, apps move between foreground and background, users sign in on multiple devices, and missed messages must be synchronized after reconnecting. To support production-oriented integrations from day one, this tutorial uses the Nexconn Production-Re

Build Real-Time Chat Across Web, iOS, Android, and Flutter with Nexconn

Build Real-Time Chat Across Web, iOS, Android, and Flutter with Nexconn

Home > Blog > Build Real-Time Chat Across Platforms Deploy production-grade in-app chat across Web, iOS, Android, and Flutter at $0 with our Free Multi-Platform Chat SDK (10K MAU). Adding a message input and a WebSocket is easy. Building chat that survives network changes, app restarts, offline periods, multiple devices, media uploads, unread state, group growth, and production traffic is a different problem. This guide shows the shortest practical path to real-time in-app chat wit