Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Flutter sample #8

Merged
merged 18 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/flutter_sample.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: flutter_sample

permissions: read-all

on:
push:
branches: [ main ]
paths:
- '.github/workflows/flutter_sample.yml'
- 'samples/flutter_app/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/flutter_sample.yml'
- 'samples/flutter_app/**'
schedule:
- cron: '0 0 * * 0' # weekly

jobs:
validate:
runs-on: ubuntu-latest
defaults:
run:
working-directory: samples/flutter_app/
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: subosito/flutter-action@02b923c0e1a5868734f1d56fa4083c3be4f554f3
with:
channel: stable
- run: flutter pub get
- run: flutter analyze --fatal-infos
- run: dart format --set-exit-if-changed .
6 changes: 3 additions & 3 deletions .github/workflows/samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ on:
branches: [ main ]
paths:
- '.github/workflows/samples.yml'
- 'samples/**'
- 'samples/dart/**'
push:
branches: [ main ]
paths:
- '.github/workflows/samples.yml'
- 'samples/**'
- 'samples/dart/**'
schedule:
- cron: '0 0 * * 0' # weekly

Expand All @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: samples
working-directory: samples/dart
strategy:
fail-fast: false
matrix:
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ documentation: https://ai.google.dev/docs

## Packages

| Package | Description | Version |
| --- | --- | --- |
| Package | Description | Version |
| -------------------------------------------------- | --- | --- |
| [google_generative_ai](pkgs/google_generative_ai/) | The Google Generative AI SDK for Dart - allows access to state-of-the-art LLMs. | |
| [samples](samples/) | Dart samples for `package:google_generative_ai`. | |
| [samples/dart](samples/dart/) | Dart samples for `package:google_generative_ai`. | |
| [samples/flutter](samples/flutter/) | Flutter sample for `package:google_generative_ai`. | |

## Contributing

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion samples/pubspec.yaml → samples/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ environment:
dependencies:
path: ^1.9.0
google_generative_ai:
path: ../pkgs/google_generative_ai
path: ../../pkgs/google_generative_ai

dev_dependencies:
lints: ^3.0.0
File renamed without changes
File renamed without changes
55 changes: 55 additions & 0 deletions samples/flutter_app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# env.json contains the API key for this sample app.
env.json

# Ignore platform-specific directories, since the user will run
# `flutter create` as described in the README
android/
web/
ios/
macos/
linux/
windows/

# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
45 changes: 45 additions & 0 deletions samples/flutter_app/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "787a51fa08ee6872245bb809c5d2ee57408d0370"
channel: "main"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
base_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
- platform: android
create_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
base_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
- platform: ios
create_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
base_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
- platform: linux
create_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
base_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
- platform: macos
create_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
base_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
- platform: web
create_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
base_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
- platform: windows
create_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370
base_revision: 787a51fa08ee6872245bb809c5d2ee57408d0370

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
26 changes: 26 additions & 0 deletions samples/flutter_app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Flutter generative AI sample

A Flutter chat application that uses the `google_generative_ai` package.

## Getting started

Create the project files for each target platform by using the `flutter create`
johnpryan marked this conversation as resolved.
Show resolved Hide resolved
command in this project's directory.

```bash
flutter create .
```

Create a new file, `env.json` to store your API key:

```json
{
"api_key": "<YOUR_API_KEY_HERE>"
}
```

Specify the `env.json` file when you run the app:

```bash
flutter run -d android --dart-define-from-file=env.json
```
3 changes: 3 additions & 0 deletions samples/flutter_app/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include: package:flutter_lints/flutter.yaml
linter:
rules:
Loading
Loading