cholai_sdk 0.0.2 copy "cholai_sdk: ^0.0.2" to clipboard
cholai_sdk: ^0.0.2 copied to clipboard

A Flutter SDK that provides socket-based chat, color theming, and user/session handling utilities.

🧠 CholAi SDK for Flutter #

A plug-and-play SDK for real-time chat and AI integration, built for fast onboarding into your Flutter app.


πŸš€ Installation #

Add the package to your pubspec.yaml:

dependencies:
  cholai_sdk: ^0.0.2  # Replace with the latest version

Then run:

flutter pub get

βš™οΈ Initialization #

Step 1: Pre-initialize the SDK in main() #

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  CholAiSdk.preInit(); // Optional: Prepares resources early
  runApp(const MyApp());
}

Step 2: Initialize SDK after login or user session is ready #

@override
void initState() {
  super.initState();
  CholAiSdk.initialize(
    userId: 'your-user-id',
    fcmToken: 'your-device-fcm-token',
    baseUrl: 'https://your-server.com', // Replace with your backend base URL
  );
}

πŸ’¬ Show Chat View #

Use the following snippet to launch a full-screen chat view between two users:

showModalBottomSheet(
  context: context,
  builder: (context) => CholAiSdk.getChatDetailView(
    senderIdParam: 'sender-id',
    senderNameParam: 'Sender Name',
    senderProfileImageParam: '',

    receiverIdParam: 'receiver-id',
    receiverNameParam: 'Receiver Name',
    receiverProfileImageParam: '',
    receiverPhoneNumberParam: '1234567890',
    receiverCountryCodeParam: '+91',
  ),
);

πŸ“± Example App #

Here’s a full working example to copy and run:

import 'package:flutter/material.dart';
import 'package:cholai_sdk/cholai_sdk.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  CholAiSdk.preInit(); // Optional: Pre-initialize SDK
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'CholAi SDK Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const HomePage(),
    );
  }
}

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    super.initState();
    CholAiSdk.initialize(
      userId: '685ed9d4ba12bfdac897d686',
      fcmToken: 'fcmToken',
      baseUrl: 'https://cholai-node.onrender.com',
    );
  }

  void _openChat() {
    showModalBottomSheet(
      context: context,
      builder: (context) => CholAiSdk.getChatDetailView(
        senderIdParam: '685ed9d4ba12bfdac897d686',
        senderNameParam: 'Sabari',
        senderProfileImageParam: '',
        receiverIdParam: '685eddd4ba12bfdac897d687',
        receiverNameParam: 'Dhina',
        receiverProfileImageParam: '',
        receiverPhoneNumberParam: '9842776133',
        receiverCountryCodeParam: '+91',
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('CholAi Chat Example')),
      body: const Center(child: Text('Tap the button to start a chat')),
      floatingActionButton: FloatingActionButton(
        onPressed: _openChat,
        child: const Icon(Icons.chat),
        tooltip: 'Start Chat',
      ),
    );
  }
}

πŸ“¦ Features #

  • πŸ”’ Secure real-time chat
  • πŸ‘₯ One-to-one chat detail view
  • πŸ”” Firebase FCM token support
  • πŸ“¦ Easy to plug into any app
  • 🎨 Theming and customization (coming soon)
0
likes
130
points
38
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter SDK that provides socket-based chat, color theming, and user/session handling utilities.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

cached_network_image, flutter, flutter_screenutil, get, get_storage, hugeicons, intl, loading_animation_widget, path, shimmer, socket_io_client

More

Packages that depend on cholai_sdk