This is a comprehensive implementation of the Qiscus Chat SDK for Flutter with a complete chat UI. The app includes all major features and follows best practices for Flutter development.
This sample demonstrates how to build a full-featured chat application using the Qiscus Chat SDK. It includes user authentication, real-time messaging, file uploads, typing indicators, presence tracking, and more.
Built with:
- ✅ Flutter 3.x
- ✅ Qiscus Chat SDK 2.2.1
- ✅ Provider for state management
- ✅ Material 3 design
- ✅ Firebase integration
-
Flutter Environment
flutter doctor
-
Firebase Setup (for Android/iOS)
- Follow Firebase Flutter Setup Guide
- Add
GoogleService-Info.plist(iOS) - Add
google-services.json(Android)
-
Qiscus App ID
- Get your App ID from Qiscus Dashboard
# Install dependencies
flutter pub get
# Run the app
flutter runlib/
├── main.dart # App entry point with providers
├── services/
│ └── qiscus_service.dart # Singleton service for SDK operations
├── providers/
│ ├── auth_provider.dart # Authentication state management
│ └── chat_provider.dart # Chat state management
└── screens/
├── splash_screen.dart # Initial loading screen
├── login_screen.dart # User authentication
├── home_screen.dart # Main navigation
├── chat_list_screen.dart # List of chat rooms
├── chat_room_screen.dart # Chat interface
├── create_chat_screen.dart # Create new chats
└── profile_screen.dart # User profile management
- ✅ Login with user credentials (userId + userKey)
- ✅ Login with JWT token
- ✅ Persistent login (auto-login on app restart)
- ✅ Logout functionality
- ✅ Profile management (name, avatar)
- ✅ Demo credentials for quick testing
- ✅ Create 1-on-1 chats
- ✅ Create group chats
- ✅ Create/join channels
- ✅ View chat room list with real-time updates
- ✅ Unread message badges
- ✅ Last message preview
- ✅ Room type indicators
- ✅ Send text messages
- ✅ Send file attachments (images, documents)
- ✅ Update messages
- ✅ Delete messages
- ✅ Clear all messages in room
- ✅ Message pagination (load previous messages)
- ✅ Message status tracking (sent, delivered, read)
- ✅ Real-time message delivery
- ✅ Typing indicators
- ✅ User presence (online/offline)
- ✅ Read receipts
- ✅ Unread count tracking
- ✅ Push notifications support
- ✅ File upload with progress tracking
- ✅ Participant management (add/remove from groups)
- ✅ Block/unblock users
- ✅ Pull-to-refresh for chat list
- ✅ Infinite scroll for message history
- ✅ Error handling and retry logic
Edit lib/services/qiscus_service.dart:
Future<void> initialize() async {
try {
const appId = 'YOUR_ACTUAL_APP_ID'; // Replace with your App ID
await sdk.setup(appId);
// ...
}
}Get your App ID from Qiscus Dashboard
Android:
- Place
google-services.jsoninandroid/app/
iOS:
- Place
GoogleService-Info.plistinios/Runner/
- Launch the app
- Enter User ID and User Key
- Optionally add display name and avatar URL
- Or click "Use Demo Credentials" for quick testing
- Tap the floating action button (+) on the Chats screen
- Choose chat type:
- 1-on-1: Enter target user ID
- Group: Enter group name and comma-separated user IDs
- Channel: Enter unique channel ID
- Open a chat room
- Type message in the input field
- Tap send button or press Enter
- Tap the attachment icon
- Choose Image or File
- Select file from device
- File uploads with progress indicator
- Go to Profile tab
- Update display name or avatar URL
- Tap "Update Profile"
Singleton Pattern
QiscusServiceprovides single instance for SDK access throughout the app
Provider Pattern
AuthProvidermanages authentication stateChatProvidermanages chat operations and real-time updates- Reactive UI updates via Provider listeners
Separation of Concerns
- Services: SDK operations and API calls
- Providers: State management and business logic
- Screens: UI presentation and user interaction
// Access providers
final authProvider = context.read<AuthProvider>();
final chatProvider = context.read<ChatProvider>();
// Watch for changes
context.watch<AuthProvider>().isLoggedIn
context.watch<ChatProvider>().messages- Show placeholder message immediately
- Upload file in background with progress
- Replace placeholder with actual message when complete
- Show progress percentage during upload
- ⏱️ Sending (clock icon)
- ✓ Sent (single check)
- ✓✓ Delivered (double check, gray)
- ✓✓ Read (double check, blue)
- Credentials saved to SharedPreferences
- Auto-login on app restart if session exists
- Automatic session recovery if SDK session expires
- Graceful fallback to login screen if credentials invalid
- Comprehensive try-catch blocks for all operations
- User-friendly error messages via SnackBars
- Loading states prevent duplicate actions
- Retry options for failed operations
- Detailed debug logging with
debugPrint
# Core
flutter: sdk: flutter
# Qiscus Chat SDK
qiscus_chat_sdk: ^2.2.1
# State Management
provider: ^6.0.5
# UI Components
cached_network_image: ^3.2.3
image_picker: ^1.0.4
file_picker: ^9.0.0
# Firebase
firebase_core: ^2.32.0
firebase_messaging: ^14.7.10
# Utilities
intl: ^0.18.1
path_provider: ^2.1.1
permission_handler: ^11.4.0
shared_preferences: ^2.2.2Android Gradle Error
- Ensure Kotlin version is 1.9.22+
- AGP should be 8.1.4+
- Gradle wrapper should be 8.4+
iOS Firebase Error
- Set
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YESin Xcode
SDK not initialized
- Verify
YOUR_ACTUAL_APP_IDis set correctly - Check internet connection
Login fails
- Confirm App ID is correct
- Verify user credentials are valid
- Check Firebase configuration
Messages not appearing
- Ensure SDK is initialized
- Verify real-time listeners are active
- Check room subscription status
File upload fails
- Verify file permissions
- Check file size limits
- Ensure stable internet connection
All SDK operations log to console with debugPrint:
🚀 Initializing Qiscus SDK
🔐 Attempting login for user: demo-user
✅ User logged in: demo-user
📨 Message received: Hello
✓ Message delivered: 12345
Use the "Use Demo Credentials" button to generate test accounts:
- User ID:
demo-user-{timestamp} - User Key:
demo-password - Display Name:
Demo User
- 1-on-1 Chat: Create chat with another user ID
- Group Chat: Add multiple user IDs
- Channel: Use a unique channel ID (e.g., "general")
- Add message search functionality
- Implement emoji picker
- Add voice/video calls
- Implement message reactions
- Add message forwarding
- Implement chat room settings
- Add user blocking UI
- Implement message encryption
Android:
iOS:
Qiscus Chat SDK Sample UI is fully open-source. All contributions and suggestions are welcome!
If you believe you have identified a security vulnerability with Qiscus Chat SDK, you should report it as soon as possible via email to [email protected]. Please do not post it to a public issue.
This implementation follows the same license as the Qiscus Chat SDK Flutter package.
For issues related to:
- This implementation: Check the code comments and this README
- Qiscus SDK: Visit Qiscus Support
- Flutter: Visit Flutter Documentation



