ai_chat_plus 1.2.3 copy "ai_chat_plus: ^1.2.3" to clipboard
ai_chat_plus: ^1.2.3 copied to clipboard

A Flutter package by jamalihassan0307 for seamless AI chat integration. Features OpenAI, Gemini, and Claude support with type-safe implementation.

AI Chat Plus Banner

๐ŸŒŸ AI Chat Plus ๐ŸŒŸ

A powerful Flutter package for AI chat integration with OpenAI, Google Gemini, and Claude AI

Created by

GitHub LinkedIn Portfolio

Pub Version Platform License: MIT

Pub Likes Pub Points Popularity


AI Chat Plus #

๐ŸŒŸ Experience the future of chat interfaces with AI Chat Plus - where intelligent chat meets modern design. Featuring seamless AI integration, real-time interactions, and multiple provider support. Built with Flutter, powered by cutting-edge AI.

๐Ÿ“ฑ Live Demos #

๐Ÿ’ฌ Simple Chat

Simple Chat Demo - Click to view full size

Quick setup with prebuilt components

๐Ÿ“‹ Implementation Details

โ€ข Single file setup
โ€ข Provider switching
โ€ข Minimal configuration

๐Ÿค– AI Integration

AI Integration Demo - Click to view full size

Multiple AI providers with seamless switching

๐Ÿ“‹ Implementation Details

โ€ข OpenAI GPT support
โ€ข Google Gemini integration
โ€ข Claude AI compatibility

๐ŸŽจ Custom Theme

Custom Theme Demo - Click to view full size

Fully customizable chat UI with themes

๐Ÿ“‹ Implementation Details

โ€ข Dynamic theme switching
โ€ข Color customization
โ€ข Layout flexibility

๐Ÿ’ก Note: Large GIF files (up to 12MB) may take a moment to load. Click on any demo image to view the full-size version.

โœจ Crafted by Jamalihassan0307 #

Transform your chat experience with:

  • โšก Real-time AI interactions with typing indicators
  • ๐Ÿค– Multiple AI providers (OpenAI, Gemini, Claude)
  • ๐Ÿ”„ Seamless provider switching
  • ๐Ÿ“ฑ Clean and efficient message handling
  • โœจ Type-safe API implementation
  • ๐Ÿ›ก๏ธ Robust error handling
  • ๐ŸŽจ Fully customizable themes and UI components
  • ๐Ÿ“Š Message persistence (Coming Soon)

๐Ÿ‘จโ€๐Ÿ’ป Developer Contact #

Key Features #

1. AI Integration โ€“ Multiple Provider Support #

// Initialize OpenAI
final openAIConfig = AIModelConfig(
  provider: AIProvider.openAI,
  apiKey: 'YOUR_OPENAI_API_KEY',
  modelId: OpenAIModel.gpt35Turbo.modelId,
);

// Initialize Gemini
final geminiConfig = AIModelConfig(
  provider: AIProvider.gemini,
  apiKey: 'YOUR_GEMINI_API_KEY',
  modelId: GeminiModel.geminiFlash.modelId,
);

// Initialize Claude
final claudeConfig = AIModelConfig(
  provider: AIProvider.claude,
  apiKey: 'YOUR_CLAUDE_API_KEY',
  modelId: ClaudeModel.claude3Sonnet.modelId,
);

2. Efficient Message Handling #

AIChat(
  apiKey: 'YOUR_API_KEY',
  provider: AIProvider.gemini,
  modelId: GeminiModel.geminiFlash.modelId,
  onError: (error) {
    print('Error: $error');
  },
)

3. Type-Safe Implementation #

CustomChatUI(
  messages: messages,
  onSendMessage: handleMessage,
  isTyping: isTyping,
  onError: handleError,
)

๐Ÿ“š Comprehensive Examples #

Explore our detailed examples to get started quickly:

๐ŸŽฏ Simple Chat Implementation #

๐Ÿ“ Location: example/simple_chat/main.dart

// Quick start with minimal setup
AIChat(
  apiKey: 'YOUR_API_KEY',
  provider: AIProvider.gemini,
  modelId: GeminiModel.geminiFlash.modelId,
)

๐Ÿค– AI Integration Examples #

๐Ÿ“ Location: example/ai_integration/

  • Main App: main.dart - Navigation between AI providers
  • OpenAI Chat: pages/openai_page.dart - GPT integration
  • Gemini Chat: pages/gemini_page.dart - Google Gemini
  • Claude Chat: pages/claude_page.dart - Anthropic Claude

๐ŸŽจ Customizable Chat UI #

๐Ÿ“ Location: example/customizable_chatui/

  • Main App: main.dart - Custom theme showcase
  • Home Page: pages/home_page.dart - Theme selection
  • Custom Chat: pages/chat_pages/custom_chat_page.dart - Full customization
  • Settings: pages/chat_pages/chat_settings_page.dart - Theme configuration

๐Ÿš€ Prebuilt Simple Chat UI #

๐Ÿ“ Location: example/prebuilt_simple_chatui/

  • Main App: main.dart - App setup
  • Test Chat: test_chat_page.dart - Ready-to-use chat interface

Features #

โœ… Currently Implemented: #

  • ๐Ÿค– OpenAI GPT Integration (GPT-3.5, GPT-4, GPT-4-turbo)
  • ๐Ÿง  Google Gemini Integration (Gemini Flash, Gemini Pro)
  • ๏ฟฝ Claude AI Integration (Claude 3 Sonnet, Opus, Haiku)
  • ๏ฟฝ๐Ÿ”„ Streaming responses support
  • ๐ŸŽฏ Type-safe API implementation
  • โšก Fast and efficient message handling
  • ๐Ÿ”„ Real-time provider switching
  • โŒจ๏ธ Typing indicators and animations
  • ๐Ÿšจ Enhanced error handling and recovery
  • ๐ŸŽจ Customizable themes and UI components
  • ๐Ÿ“ฑ Multiple chat UI options (Simple, Custom, Prebuilt)
  • ๐ŸŒ Cross-platform support (Android, iOS, Web)
  • ๐Ÿ›ก๏ธ Secure API key management

๐Ÿš€ Coming Soon: #

  • ๐Ÿ’พ Message Storage & Persistence
    • ๐Ÿ”ฅ Firebase Firestore integration
    • ๐Ÿ“ฑ Local SQLite storage
    • โ˜๏ธ Cloud sync capabilities
    • ๐Ÿ“Š Chat history management
  • ๐ŸŽค Voice Features
    • ๐Ÿ—ฃ๏ธ Speech-to-text integration
    • ๐Ÿ”Š Text-to-speech responses
    • ๐ŸŽต Voice message support
  • ๐Ÿ“ File & Media Support
    • ๐Ÿ“Ž File attachments
    • ๐Ÿ–ผ๏ธ Image sharing and analysis
    • ๐Ÿ“„ Document processing
  • ๐Ÿ” Advanced Features
    • ๐Ÿ” Message search functionality
    • ๐Ÿท๏ธ Chat categorization and tagging
    • ๐Ÿ“ˆ Usage analytics and insights
    • ๐ŸŒ Multi-language support
  • ๐ŸŽฎ Enhanced UI/UX
    • ๐ŸŒ™ Dark/Light theme auto-switching
    • ๐Ÿ“ฑ Adaptive design improvements
    • โœจ Animation enhancements
    • ๐ŸŽจ More theme presets

Usage #

Basic Setup #

Add this to your package's pubspec.yaml file:

dependencies:
  ai_chat_plus: ^1.2.3

Then run:

flutter pub get

Using OpenAI Service #

import 'package:ai_chat_plus/ai_chat_plus.dart';

Future<void> initOpenAI() async {
  final config = AIModelConfig(
    provider: AIProvider.openAI,
    apiKey: 'YOUR_OPENAI_API_KEY',
    modelId: OpenAIModel.gpt35Turbo.modelId,
  );

  final aiService = AIServiceFactory.createService(AIProvider.openAI);
  await aiService.initialize(config);
  
  // Generate response
  final response = await aiService.generateResponse("Hello, how are you?");
  print(response);
}

Using Gemini Service #

import 'package:ai_chat_plus/ai_chat_plus.dart';

Future<void> initGemini() async {
  final config = AIModelConfig(
    provider: AIProvider.gemini,
    apiKey: 'YOUR_GEMINI_API_KEY',
    modelId: GeminiModel.geminiFlash.modelId,
  );

  final aiService = AIServiceFactory.createService(AIProvider.gemini);
  await aiService.initialize(config);
  
  // Generate response
  final response = await aiService.generateResponse("What is quantum computing?");
  print(response);
}

Using Claude Service #

import 'package:ai_chat_plus/ai_chat_plus.dart';

Future<void> initClaude() async {
  final config = AIModelConfig(
    provider: AIProvider.claude,
    apiKey: 'YOUR_CLAUDE_API_KEY',
    modelId: ClaudeModel.claude3Sonnet.modelId,
  );

  final aiService = AIServiceFactory.createService(AIProvider.claude);
  await aiService.initialize(config);
  
  // Generate response
  final response = await aiService.generateResponse("What is artificial intelligence?");
  print(response);
}

Creating a Chat Application #

To create a chat application with both OpenAI and Gemini support:

  1. Create separate pages for each service:
// Create OpenAI chat page
class OpenAIChatPage extends StatefulWidget {
  // ... implementation in example/pages/openai_page.dart
}

// Create Gemini chat page
class GeminiChatPage extends StatefulWidget {
  // ... implementation in example/pages/gemini_page.dart
}
  1. Set up navigation between services:
class ChatScreen extends StatefulWidget {
  @override
  State<ChatScreen> createState() => _ChatScreenState();
}

class _ChatScreenState extends State<ChatScreen> {
  int _selectedIndex = 0;
  final List<Widget> _pages = [
    const GeminiChatPage(),
    const OpenAIChatPage(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _pages[_selectedIndex],
      bottomNavigationBar: BottomNavigationBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(Icons.psychology),
            label: 'Gemini',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.chat_bubble),
            label: 'OpenAI',
          ),
        ],
        currentIndex: _selectedIndex,
        onTap: (index) => setState(() => _selectedIndex = index),
      ),
    );
  }
}

๐Ÿš€ Prebuilt Chat UI - Quick Start #

Get started in minutes with our prebuilt chat interface:

AIChat(
  apiKey: 'YOUR_API_KEY',
  provider: AIProvider.gemini,
  modelId: GeminiModel.geminiFlash.modelId,
  primaryColor: Theme.of(context).primaryColor,
  backgroundColor: Colors.grey[100],
  // Provider switching
  onProviderChanged: (AIProvider newProvider) {
    return AIModelConfig(
      provider: newProvider,
      apiKey: getApiKeyForProvider(newProvider),
      modelId: getDefaultModelForProvider(newProvider),
    );
  },
  // Error handling
  onError: (error) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text(error.toString())),
    );
  },
)

๐ŸŽจ Custom Chat UI - Full Control #

For complete customization, use our custom chat components:

CustomChatUI(
  messages: _messages,
  onSendMessage: _handleSendMessage,
  isTyping: _isTyping,
  theme: ChatTheme(
    primaryColor: Colors.purple,
    backgroundColor: const Color(0xFFF0F0F0),
    userBubbleGradient: const LinearGradient(
      colors: [Colors.purple, Colors.deepPurple],
    ),
    aiBubbleColor: Colors.white,
    bubbleRadius: 20,
    // ... more customization options
  ),
  userAvatarUrl: 'https://example.com/user-avatar.png',
  aiAvatarUrl: 'https://example.com/ai-avatar.png',
  enableAttachments: true,
)

๐Ÿ“ฑ Multi-Provider Chat App #

Create an app with multiple AI providers:

class ChatApp extends StatefulWidget {
  @override
  State<ChatApp> createState() => _ChatAppState();
}

class _ChatAppState extends State<ChatApp> {
  AIProvider _currentProvider = AIProvider.gemini;
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('AI Chat Plus'),
        actions: [
          PopupMenuButton<AIProvider>(
            onSelected: (provider) {
              setState(() => _currentProvider = provider);
            },
            itemBuilder: (context) => [
              PopupMenuItem(value: AIProvider.openAI, child: Text('OpenAI')),
              PopupMenuItem(value: AIProvider.gemini, child: Text('Gemini')),
              PopupMenuItem(value: AIProvider.claude, child: Text('Claude')),
            ],
          ),
        ],
      ),
      body: AIChat(
        apiKey: _getApiKey(_currentProvider),
        provider: _currentProvider,
        modelId: _getDefaultModel(_currentProvider),
      ),
    );
  }
}

๐Ÿ”ง Key Features #

Prebuilt UI Features:

  • ๐Ÿ”„ Built-in provider switching (OpenAI, Gemini, Claude)
  • ๐ŸŽจ Customizable themes and colors
  • ๐Ÿšจ Error handling and loading states
  • ๐Ÿ’ฌ Message bubble customization
  • โŒจ๏ธ Input field styling
  • ๐Ÿ“ฑ Responsive design

Custom UI Features:

  • ๐ŸŽ›๏ธ Complete theme control
  • ๐Ÿ‘ค Custom avatars and profiles
  • ๐Ÿ“Ž Attachment support
  • โœจ Animation customization
  • ๐ŸŒˆ Gradient backgrounds
  • ๐Ÿ“ Flexible layouts

For detailed implementation examples, check:

  • Simple Usage: example/simple_chat/
  • AI Integration: example/ai_integration/
  • Custom Themes: example/customizable_chatui/
  • Prebuilt UI: example/prebuilt_simple_chatui/

๐Ÿ“š API Documentation #

๐Ÿ”‘ API Keys Setup

  1. OpenAI API Key: Get from OpenAI Platform
  2. Gemini API Key: Get from Google AI Studio
  3. Claude API Key: Get from Claude AI Platform

๐Ÿค– Available Models

OpenAI Models:

  • OpenAIModel.gpt35Turbo - Fast and efficient
  • OpenAIModel.gpt4 - Most capable model
  • OpenAIModel.gpt4Turbo - Optimized GPT-4

Gemini Models:

  • GeminiModel.geminiFlash - Fast responses
  • GeminiModel.geminiPro - Balanced performance
  • GeminiModel.geminiPro15 - Enhanced capabilities

Claude Models:

  • ClaudeModel.claude3Haiku - Fast and lightweight
  • ClaudeModel.claude3Sonnet - Balanced performance
  • ClaudeModel.claude3Opus - Most capable Claude model

๐Ÿ›ก๏ธ Security Best Practices

// โœ… Good: Use environment variables
final apiKey = const String.fromEnvironment('OPENAI_API_KEY');

// โŒ Bad: Hardcoded API keys
final apiKey = 'sk-your-actual-key-here'; // Never do this!

// โœ… Good: Error handling
try {
  final response = await aiService.generateResponse(message);
  // Handle success
} catch (e) {
  // Handle error gracefully
  print('Error: $e');
}

// โœ… Good: Proper cleanup
@override
void dispose() {
  aiService.dispose();
  super.dispose();
}

๐Ÿ”ง Advanced Configuration

// Custom service configuration
final config = AIModelConfig(
  provider: AIProvider.openAI,
  apiKey: 'YOUR_API_KEY',
  modelId: OpenAIModel.gpt4Turbo.modelId,
  // Optional: Custom parameters
  maxTokens: 2048,
  temperature: 0.7,
  topP: 1.0,
);

// Initialize service with custom config
final aiService = AIServiceFactory.createService(AIProvider.openAI);
await aiService.initialize(config);

๐ŸŽฏ Performance Tips #

  1. Service Reuse: Initialize services once and reuse them
  2. Proper Disposal: Always dispose services to prevent memory leaks
  3. Error Handling: Implement robust error handling for better UX
  4. Streaming: Use streaming for real-time responses where supported
  5. Model Selection: Choose appropriate models based on your use case

๐Ÿš€ Future Roadmap #

Version 1.3.0 (Next Release) #

  • ๐Ÿ”ฅ Firebase Firestore integration for message persistence
  • ๐Ÿ“ฑ Local SQLite storage for offline capabilities
  • ๐ŸŽค Voice message recording and playback
  • ๐Ÿ“ท Image upload and analysis support

Version 1.4.0 (Upcoming) #

  • ๐Ÿ” Advanced search functionality
  • ๐Ÿท๏ธ Message categorization and tagging
  • ๐Ÿ“Š Usage analytics and insights
  • ๐ŸŒ Multi-language support

Version 1.5.0 (Future) #

  • ๐ŸŽจ Enhanced theme system with more presets
  • ๐Ÿค– Custom AI model integration support
  • ๐Ÿ“ฑ Improved mobile responsiveness
  • โšก Performance optimizations

๐Ÿค Contributing #

We welcome contributions! Please see our Contributing Guidelines for details.

Ways to Contribute: #

  • ๐Ÿ› Report bugs and issues
  • ๐Ÿ’ก Suggest new features
  • ๐Ÿ“ Improve documentation
  • ๐Ÿงช Add tests
  • ๐ŸŽจ Enhance UI/UX

๐Ÿ“ž Support & Community #

โญ Show Your Support #

If you find AI Chat Plus helpful, please:

  • โญ Star the repository on GitHub
  • ๐Ÿ‘ Like the package on pub.dev
  • ๐Ÿ“ข Share with other developers
  • ๐Ÿ’ Consider sponsoring the project

๐Ÿ“„ License #

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘จโ€๐Ÿ’ป About the Developer #

Jam Ali Hassan

Jam Ali Hassan

Passionate Flutter developer creating innovative solutions for the mobile development community.

GitHub LinkedIn Portfolio

๐Ÿ“ง Email: jamalihassan0307@gmail.com


Made with โค๏ธ by Jam Ali Hassan

ยฉ 2024 AI Chat Plus. All rights reserved.

8
likes
160
points
210
downloads
screenshot

Publisher

unverified uploader

Weekly Downloads

A Flutter package by jamalihassan0307 for seamless AI chat integration. Features OpenAI, Gemini, and Claude support with type-safe implementation.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dart_openai, equatable, flutter, flutter_web_plugins, freezed_annotation, google_generative_ai, http, json_annotation, provider, universal_io, web_socket_channel

More

Packages that depend on ai_chat_plus