Skip to main content

ai_assistant_ui 0.0.1 copy "ai_assistant_ui: ^0.0.1" to clipboard
ai_assistant_ui: ^0.0.1 copied to clipboard

A customizable, modern AI Chat UI library for Flutter supporting Google Gemini, OpenAI, Claude, Ollama, dynamic light/dark themes, and chat history persistence.

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  ThemeMode _themeMode = ThemeMode.dark;

  void _toggleTheme() {
    setState(() {
      _themeMode = _themeMode == ThemeMode.dark
          ? ThemeMode.light
          : ThemeMode.dark;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'AI Demo',
      debugShowCheckedModeBanner: false,
      themeMode: _themeMode,
      theme: ThemeData.light(useMaterial3: true),
      darkTheme: ThemeData.dark(useMaterial3: true),
      home: ChatScreen(
        onThemeToggle: _toggleTheme,
        isDarkMode: _themeMode == ThemeMode.dark,
      ),
    );
  }
}

class ChatScreen extends StatelessWidget {
  final VoidCallback onThemeToggle;
  final bool isDarkMode;

  const ChatScreen({
    super.key,
    required this.onThemeToggle,
    required this.isDarkMode,
  });

  @override
  Widget build(BuildContext context) {
    // 1. Initialize AI Provider (e.g. Gemini, OpenAI, Claude, or Ollama)
    final provider = GeminiProvider(
      apiKey: 'YOUR_GEMINI_API_KEY', // Replace with your actual Gemini API Key
      model: 'gemini-1.5-flash',
    );

    // 2. Configure Chat Options
    const config = AIChatConfig(
      title: 'Title',
      placeholderText: 'Ask anything...',
      welcomeMessage: 'How can I help you today?',
      enableHistoryDrawer: true,
      enableMarkdown: true,
    );

    return Scaffold(
      body: AIChatView(
        provider: provider,
        config: config,
        isDarkMode: isDarkMode,
        onThemeToggle: onThemeToggle,
        storage: HiveChatStorage(), // Persistent storage via Hive
      ),
    );
  }
}
2
likes
140
points
179
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A customizable, modern AI Chat UI library for Flutter supporting Google Gemini, OpenAI, Claude, Ollama, dynamic light/dark themes, and chat history persistence.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

dio, equatable, flutter, flutter_bloc, flutter_markdown, hive, hive_flutter

More

Packages that depend on ai_assistant_ui