flutter_ai_chat 0.1.0
flutter_ai_chat: ^0.1.0 copied to clipboard
AI chat interface with streaming responses and conversation management
Flutter AI Chat #
A modern, cross-platform AI chat interface built with Flutter that supports streaming responses and conversation management.
Features #
- ๐ค AI Chat Interface - Chat with AI models using OpenAI API
- ๐ฑ Cross-Platform Support - Works on iOS, Android, Web, Windows, macOS, and Linux
- ๐ Streaming Responses - Real-time AI responses with streaming support
- ๐ฌ Conversation Management - Create, manage, and organize chat conversations
- ๐จ Modern UI/UX - Beautiful Material Design 3 interface with light/dark themes
- ๐ฑ Responsive Design - Adapts to different screen sizes and orientations
- ๐ Secure - Secure API key management and data handling
- โก Web Optimized - Optimized web build with CanvasKit renderer for better performance
- ๐งช High Quality - Analyzed with Pana, Flutter analyze, and Dart analysis
Preview #
Platform Support #
| Platform | Status | Notes |
|---|---|---|
| iOS | โ Supported | iPhone and iPad |
| Android | โ Supported | Phone and Tablet |
| Web | โ Supported | Chrome, Firefox, Safari, Edge |
| Windows | โ Supported | Desktop |
| macOS | โ Supported | Desktop |
| Linux | โ Supported | Desktop |
Getting Started #
Prerequisites #
- Flutter SDK: >=3.32.0
- Dart SDK: >=3.8.0
- OpenAI API Key (for AI functionality)
Installation #
- Clone the repository:
git clone https://github.com/Dhia-Bechattaoui/flutter_ai_chat.git
cd flutter_ai_chat
- Install dependencies:
flutter pub get
-
Configure your OpenAI API key:
- Create a
.envfile in the root directory (for package-level usage) - Add your API key:
OPENAI_API_KEY=your_api_key_here - For the example app, place the
.envinsideexample/.env
- Create a
-
Run the example app (recommended to see all features):
cd example
flutter run
- Use the package in your app:
dependencies:
flutter_ai_chat: ^0.1.0
Web Deployment #
For web deployment with optimized rendering:
flutter build web --web-renderer canvaskit
This uses CanvasKit renderer for better performance and consistency across browsers.
Configuration #
Environment Variables #
Create a .env file in the root directory:
OPENAI_API_KEY=your_openai_api_key_here
For the example app, place the file at example/.env with the same key.
API Configuration #
The app is configured to use OpenAI's GPT models by default. You can modify the configuration in lib/services/ai_service.dart (model, base URL, timeouts, headers).
Architecture #
The project follows a clean architecture pattern with the following structure:
lib/
โโโ flutter_ai_chat.dart # Package exports
โโโ models/ # Data models
โ โโโ chat_message.dart # Chat message model
โ โโโ conversation.dart # Conversation model
โโโ providers/ # State management
โ โโโ chat_provider.dart # Chat state provider
โโโ screens/ # UI screens
โ โโโ chat_screen.dart # Main chat interface
โโโ services/ # Business logic
โ โโโ ai_service.dart # AI API service
โโโ utils/ # Utilities
โ โโโ theme.dart # App theme configuration
โโโ widgets/ # Reusable widgets
โโโ chat_input_widget.dart
โโโ chat_message_widget.dart
โโโ sidebar_widget.dart
Dependencies #
Core Dependencies #
flutter- Flutter SDKprovider- State managementhttp- HTTP client for API callsdio- HTTP client (used for streaming responses)shared_preferences/sqflite- Local storageflutter_markdown_plus- Markdown rendering for AI responsesflutter_dotenv- Environment variable management
Development Dependencies #
flutter_lints- Code quality rulesflutter_test- Testing frameworkmockito- Mocking for testsdartdoc- Documentation generation
Quality Assurance #
This project maintains high code quality standards:
- โ Pana Analysis - Full score compliance
- โ Flutter Analyze - No analysis issues
- โ Dart Analysis - Clean code standards
- โ Linting - Strict linting rules
- โ Testing - Comprehensive test coverage including unit tests for services, models, and providers
Contributing #
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
Testing #
Run the test suite:
flutter test
Run with coverage:
flutter test --coverage
Building for Production #
Android #
flutter build apk --release
iOS #
flutter build ios --release
Web #
flutter build web --release --web-renderer canvaskit
Desktop #
flutter build windows --release
flutter build macos --release
flutter build linux --release
License #
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments #
- Flutter team for the amazing framework
- OpenAI for providing the AI API
- Material Design team for the design system
- All contributors and supporters
Support #
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Contact the maintainer: Dhia-Bechattaoui
Roadmap #
- โ Voice input support
- โ Image generation integration
- โ Multi-language support
- โ Offline mode
- โ Advanced conversation analytics
- โ Plugin system for custom AI providers
Made with โค๏ธ using Flutter