A Flutter-based AI chat application powered by the Google Gemini API. The application provides a modern conversational interface with real-time streaming responses, multi-session chat management, and a clean architecture designed for scalability and maintainability.
- Real-time streaming responses
- Chat interface with distinct user and AI message bubbles
- Input field with send button
- Automatic scrolling to the latest message
- Typing indicator while the AI generates responses
- Stop streaming button to halt response generation
- Copy message button for quick message copying
- Markdown rendering with proper formatting and code block support
- Multi-session chat support
- Sidebar navigation to create and switch between chat sessions
- Clear chat option
- Local storage of chat history using
shared_preferences
- Dark mode and light mode support
- Responsive and modern chat UI design
- Streaming API integration for real-time updates
- Robust error handling for network failures, timeouts, and API errors
The project follows Clean Architecture principles to ensure separation of concerns, maintainability, and scalability. The codebase is structured into four primary layers:
Contains the UI components and state management logic, including pages, widgets, and providers responsible for managing UI state and user interactions.
Contains the core business logic of the application, including use cases (such as SendMessage) and abstract repository definitions. This layer is independent of frameworks and external libraries.
Responsible for data retrieval and implementation of repository interfaces defined in the domain layer. It includes remote and local data sources such as GeminiRemoteDatasource.
Contains shared utilities, constants, and configurations used across the application, including AppConstants.
The application uses Provider for state management.
- Provider enables efficient sharing and updating of application state across widgets.
- It manages chat messages, sessions, and UI updates in a centralized manner.
- Widgets listen to state changes and rebuild only when necessary,mproving performance.
- This approach helps maintain a clear separation between UI and business logic.
-
Clone the repository.
-
Install dependencies:
flutter pub get
Run the app: with your API key flutter run --dart-define=GEMINI_API_KEY="your_api_key_here"