A Flutter application that demonstrates on-device AI chat capabilities using the Cactus Flutter library. This app runs AI models locally on your device, providing privacy-focused conversational AI without requiring an internet connection for inference.
- 🤖 On-Device AI: Runs AI models locally using Cactus Flutter
- 💬 Chat Interface: Clean, Material 3 chat UI with message bubbles
- 📥 Model Download: Automatic model downloading with progress tracking
- 🎨 Markdown Support: Rich text rendering for AI responses
- 🔄 State Management: Built with Riverpod for reactive state management
- 🧹 Chat Management: Clear conversation history with a single tap
Before you begin, ensure you have the following installed:
- Flutter SDK: Version 3.10.0 or higher
- Dart SDK: Comes bundled with Flutter
- Platform-specific requirements:
- iOS: Xcode 14+ and CocoaPods
- Android: Android Studio with Android SDK
- macOS/Linux/Windows: Platform-specific development tools
-
Clone the repository (or navigate to the project directory):
cd /path/to/on_device_app -
Install dependencies:
flutter pub get
-
Generate code (for Riverpod and Freezed):
flutter pub run build_runner build --delete-conflicting-outputs
-
Platform-specific setup:
cd ios pod install cd ..
No additional setup required beyond having Android SDK installed.
-
Check available devices:
flutter devices
-
Run the app:
flutter run
Or specify a device:
flutter run -d <device-id>
-
Using the app:
- On first launch, tap "Initialize Model (qwen3-0.6)" to download the AI model
- Wait for the model download to complete (progress is shown)
- Once initialized, type your message and press send
- The AI will respond locally on your device
lib/
├── main.dart # App entry point
├── chat/
│ ├── chat_screen.dart # Main chat UI
│ ├── chat_provider.dart # Chat state management
│ ├── chat_state.dart # Chat state model
│ └── message_bubble.dart # Message UI component
├── core/ # Core utilities
└── providers/ # Additional providers
- cactus: On-device AI inference
- hooks_riverpod: State management and dependency injection
- flutter_hooks: React-like hooks for Flutter
- freezed: Immutable state classes
- flutter_markdown_plus: Markdown rendering for AI responses
If you encounter header errors or build failures on iOS:
cd ios
rm -rf Pods Podfile.lock
pod install
cd ..
flutter clean
flutter pub get- Ensure you have a stable internet connection
- Check available storage space on your device
- Try clearing the app data and reinitializing
- Run
flutter cleanand rebuild - Ensure all dependencies are properly installed
- Check device logs:
flutter logs
To contribute or modify the app:
-
Watch for code generation changes:
flutter pub run build_runner watch
-
Run tests:
flutter test -
Format code:
flutter format . -
Analyze code:
flutter analyze
This project is for educational and demonstration purposes.