atomicbi_flutter_ai 1.0.2 copy "atomicbi_flutter_ai: ^1.0.2" to clipboard
atomicbi_flutter_ai: ^1.0.2 copied to clipboard

A set of AI chat-related widgets for Flutter apps targeting mobile, desktop, and web.

example/lib/main.dart

import 'package:atomicbi_flutter_ai/atomicbi_flutter_ai.dart';
import 'package:atomicbi_flutter_ai_example/chunks.dart';
import 'package:atomicbi_flutter_ai_example/stub.dart';
import 'package:flutter/material.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const App());
}

final theme = ThemeData(
  brightness: Brightness.dark,
  primaryColor: const Color(0xff54346b),
  colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xff54346b), brightness: Brightness.dark),
  textTheme: const TextTheme(bodyMedium: TextStyle(color: Color(0xffeeeeee), fontSize: 14)),
  snackBarTheme: SnackBarThemeData(
    behavior: SnackBarBehavior.floating,
    showCloseIcon: true,
    closeIconColor: const Color(0xffeeeeee),
    insetPadding: EdgeInsets.all(16),
    backgroundColor: const Color(0xff54346b),
    contentTextStyle: TextStyle(color: const Color(0xffeeeeee))
  ),
  tooltipTheme: TooltipThemeData(
    textStyle: TextStyle(color: const Color(0xffe9eef8)),
    decoration: BoxDecoration(
      color: const Color(0xff121721),
      border: Border.all(
        color: const Color(0xff04070f),
        style: BorderStyle.solid,
        width: 1
      ),
      borderRadius: BorderRadius.all(Radius.circular(4))
    )
  ),
);


class App extends StatelessWidget {
  const App({ super.key });

  @override
  Widget build(BuildContext context) => MaterialApp(
    title: 'Atomic BI AI',
    home: const ChatPage(),
    theme: theme,
    debugShowCheckedModeBanner: false
  );
}

class ChatPage extends StatelessWidget {
  const ChatPage({super.key});

  @override
  Widget build(BuildContext context) => Scaffold(
    body: Container(
      constraints: BoxConstraints(minHeight: double.infinity),
      decoration: BoxDecoration(
        gradient: LinearGradient(
          begin: Alignment.topLeft,
          end: Alignment.bottomRight,
          colors: [Color(0xff1F122F), Color(0xff121B21)]
        )
      ),
      child: ChatView(
        welcomeMessage: 'Hi there, how are you today?',
        responseBuilder: (context, response) => MarkdownView(response),
        renderIcon: (chunk) {
          final String? agentId = chunk?.data['messageMetadata']?['operator']?['id'] ?? 'dznjrwny';
          final url = 'https://vpuwtbbaybnwcpfidqtl.supabase.co/storage/v1/object/public/cdn/spaces/yoexoexl/agents/$agentId.png';
          return Container(
            decoration: BoxDecoration(
              border: Border.all(color: const Color(0x14deeeff), style: BorderStyle.solid, width: 1),
              borderRadius: BorderRadius.circular(20),
              color: const Color(0x14deeeff)
            ),
            child: Image.network(
              url,
              cacheHeight: 38,
              cacheWidth: 38,
              width: 38,
              height: 38,
              errorBuilder: (context, error, stackTrace) => Container(
                width: 38,
                height: 38,
                color: const Color(0xff92549c),
                child: Icon(Icons.person),
              )
            )
          );
        },
        onReportCallback: (context, message, text) {
          print('report: $text');
        },
        provider: MockProvider(
          chunks: chunks,
          initialDelay: Duration(milliseconds: 2000),
          chunkDelay: Duration(milliseconds: 50),
          history: [
            ChatMessage.user(text: 'What is 2 + 2?'),
            ChatMessage.agent(text: stubThinkTag)
          ]
        )
      )
    )
  );
}
0
likes
140
points
163
downloads

Publisher

unverified uploader

Weekly Downloads

A set of AI chat-related widgets for Flutter apps targeting mobile, desktop, and web.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, flutter_context_menu, google_fonts, gpt_markdown

More

Packages that depend on atomicbi_flutter_ai