aircloud_in_app_chat 0.0.1
aircloud_in_app_chat: ^0.0.1 copied to clipboard
A Flutter package for easy integration of in-app chat functionality, powered by AirCloud. This package provides UI components and backend integration to add real-time messaging to your Flutter application
A Flutter package for easy integration of in-app chat functionality, powered by AirCloud. This package provides UI components and backend integration to add real-time messaging to your Flutter application.
Features #
- 💬 Real-time Messaging: One-to-one and group chats.
- 🎨 Customizable UI: Pre-built, but customizable, widgets for chat lists, chat screens, and message bubbles.
- 🚀 Push Notifications: Keep users engaged with notifications for new messages.
- 📎 Attachments: Support for sending and receiving images, videos, and other files.
- 👀 User Presence: Real-time online/offline status indicators.
- ✔️ Read Receipts: See when your messages have been delivered and read.
- ✍️ Typing Indicators: Know when the other person is typing a message.
Getting started #
Prerequisites #
- You need a Flutter environment. See Flutter's documentation for help.
- An account with AirCloud to get your API keys.
Installation #
Add aircloud_in_app_chat to your pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
aircloud_in_app_chat: ^0.0.1 # Replace with the latest version
Then, run flutter pub get in your terminal.
Initialization #
Before using the package, you need to initialize it, preferably in your main.dart file.
import 'package:flutter/material.dart';
import 'package:aircloud_in_app_chat/aircloud_in_app_chat.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// TODO: Replace with your actual AirCloud API Key
await AirCloudChat.initialize(
apiKey: 'YOUR_AIRCLOUD_API_KEY',
restUrl:'YOUR_AIRCLOUD_REST_URL');
runApp(MyApp());
}
Usage #
Here is a small example of how to display a list of chat conversations and open a chat screen.
Displaying a list of chats #
import 'package:flutter/material.dart';
import 'package:aircloud_in_app_chat/aircloud_in_app_chat.dart';
class ChatListScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Chats')),
body: FutureBuilder<List<Chat>>(
future: AirCloudChat.instance.getChats(), // Fetch user's chats
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator());
}
if (snapshot.hasError) {
return Center(child: Text('Error: ${snapshot.error}'));
}
if (!snapshot.hasData || snapshot.data!.isEmpty) {
return Center(child: Text('No chats yet.'));
}
final chats = snapshot.data!;
return ListView.builder(
itemCount: chats.length,
itemBuilder: (context, index) {
final chat = chats[index];
return ListTile(
leading: CircleAvatar(
// TODO: Use chat avatar URL
// backgroundImage: NetworkImage(chat.avatarUrl),
),
title: Text(chat.name), // TODO: Use chat name
subtitle: Text(chat.lastMessage.text), // TODO: Use last message
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ChatScreen(chatId: chat.id),
),
);
},
);
},
);
},
),
);
}
}
Opening a chat screen #
The package provides a ChatScreen widget that you can push onto the navigation stack.
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ChatScreen(chatId: 'some_chat_id'),
),
);
Additional information #
Contributing & Issues #
Contributions are welcome! If you would like to contribute, please fork the repository and submit a pull request.
If you encounter any problems or have suggestions, please file an issue on the package's GitHub repository (you may need to add the link here).
License #
This package is licensed under the MIT License - see the LICENSE file for details.