Zack Saadioui
8/28/2024
1
flutter create my_ai_app
1
cd my_ai_app
1
pubspec.yaml
1
2
3
4
5
yaml
dependencies:
flutter:
sdk: flutter
google_generative_ai: ^0.2.2 # Check for updates on pub.dev
1
flutter pub get
1
2
3
4
5
dart
final model = GenerativeModel(
model: 'gemini-pro',
apiKey: 'YOUR_API_KEY',
);
1
2
3
4
5
dart
final response = await model.generateContent(
[Content.text('What is Flutter?')],
);
print(response);
1
2
3
4
5
dart
var chatModel = model.startChat();
final content = Content.text('Hello! How can I assist you today?');
var chatResponse = await chatModel.sendMessage(content);
print(chatResponse);
Copyright © Arsturn 2024