dartantic_chat 0.1.0
dartantic_chat: ^0.1.0 copied to clipboard
AI chat widget for Flutter apps targeting mobile, desktop, and web supporting text, image, and voice input.
// Copyright 2024 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:dartantic_ai/dartantic_ai.dart';
import 'package:flutter/material.dart';
import 'package:dartantic_chat/dartantic_chat.dart';
const _apiKey = String.fromEnvironment('GEMINI_API_KEY');
void main() {
assert(_apiKey.isNotEmpty, 'GEMINI_API_KEY not provided via --dart-define');
Agent.environment['GEMINI_API_KEY'] = _apiKey;
runApp(const App());
}
class App extends StatelessWidget {
static const title = 'Example: Google Gemini AI';
const App({super.key});
@override
Widget build(BuildContext context) =>
const MaterialApp(title: title, home: ChatPage());
}
class ChatPage extends StatelessWidget {
const ChatPage({super.key});
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text(App.title)),
body: AgentChatView(provider: DartanticProvider(agent: Agent('gemini'))),
);
}