first test ok

This commit is contained in:
Valentin CZERYBA 2024-07-17 22:49:47 +02:00
parent 103046b5a4
commit fccf4f0832
5 changed files with 48 additions and 38 deletions

View File

@ -45,3 +45,5 @@ app.*.map.json
/android/app/debug /android/app/debug
/android/app/profile /android/app/profile
/android/app/release /android/app/release
.env

View File

@ -4,7 +4,6 @@ import 'dart:io';
import 'DisplayPictureScreen.dart'; import 'DisplayPictureScreen.dart';
import 'package:camera/camera.dart'; import 'package:camera/camera.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gemini/flutter_gemini.dart';
Future<void> main() async { Future<void> main() async {
// Ensure that plugin services are initialized so that `availableCameras()` // Ensure that plugin services are initialized so that `availableCameras()`
@ -14,8 +13,6 @@ Future<void> main() async {
// Obtain a list of the available cameras on the device. // Obtain a list of the available cameras on the device.
final cameras = await availableCameras(); final cameras = await availableCameras();
Gemini.init(apiKey: 'AIzaSyAt1LQIV_hwJQF56sXjb4oxEZEC0wI3PKg');
// Get a specific camera from the list of available cameras. // Get a specific camera from the list of available cameras.
final firstCamera = cameras.first; final firstCamera = cameras.first;

View File

@ -1,11 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:io'; import 'dart:io';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_gemini/flutter_gemini.dart'; import 'package:flutter_gemini/flutter_gemini.dart';
void main() { void main() {
Gemini.init(apiKey: 'AIzaSyAt1LQIV_hwJQF56sXjb4oxEZEC0wI3PKg');
runApp(MyApp()); runApp(MyApp());
} }
@ -54,8 +53,10 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen> {
} }
Future<void> _getEventInfosFromImage() async { Future<void> _getEventInfosFromImage() async {
Gemini.init(apiKey: 'AIzaSyAt1LQIV_hwJQF56sXjb4oxEZEC0wI3PKg'); await dotenv.load();
final gemini = Gemini.instance;
final gemini = Gemini.init(
apiKey: dotenv.env['GEMINI_API_KEY']!, enableDebugging: true);
final file = File(widget.imagePath); final file = File(widget.imagePath);
@ -63,7 +64,7 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen> {
.textAndImage( .textAndImage(
text: "What is this picture ?", images: [file.readAsBytesSync()]) text: "What is this picture ?", images: [file.readAsBytesSync()])
.then((value) => print(value?.content?.parts?.last.text ?? '')) .then((value) => print(value?.content?.parts?.last.text ?? ''))
.catchError((e) => print(e)); .catchError((e) => print("problem gemini : ${e}"));
} }
@override @override

View File

@ -29,34 +29,34 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: camera_android_camerax name: camera_android_camerax
sha256: c6b6a637fc72471dc82c72d06b1a7edd8390477d8dbe026fed6c2f34f04f6d06 sha256: "7c03940cb8c92eb5b184952674a07cc4a73c6ba2b3568aad70255ad4cb913660"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.6" version: "0.6.7+1"
camera_avfoundation: camera_avfoundation:
dependency: transitive dependency: transitive
description: description:
name: camera_avfoundation name: camera_avfoundation
sha256: "7d021e8cd30d9b71b8b92b4ad669e80af432d722d18d6aac338572754a786c15" sha256: b5093a82537b64bb88d4244f8e00b5ba69e822a5994f47b31d11400e1db975e5
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.9.16" version: "0.9.17+1"
camera_platform_interface: camera_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: camera_platform_interface name: camera_platform_interface
sha256: a250314a48ea337b35909a4c9d5416a208d736dcb01d0b02c6af122be66660b0 sha256: b3ede1f171532e0d83111fe0980b46d17f1aa9788a07a2fbed07366bbdbb9061
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.7.4" version: "2.8.0"
camera_web: camera_web:
dependency: "direct main" dependency: "direct main"
description: description:
name: camera_web name: camera_web
sha256: "9e9aba2fbab77ce2472924196ff8ac4dd8f9126c4f9a3096171cd1d870d6b26c" sha256: b9235ec0a2ce949daec546f1f3d86f05c3921ed31c7d9ab6b7c03214d152fc2d
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.3.3" version: "0.3.4"
characters: characters:
dependency: transitive dependency: transitive
description: description:
@ -85,10 +85,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: cross_file name: cross_file
sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32" sha256: "2f9d2cbccb76127ba28528cb3ae2c2326a122446a83de5a056aaa3880d3882c5"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.3.4+1" version: "0.3.3+7"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@ -142,6 +142,14 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_dotenv:
dependency: "direct main"
description:
name: flutter_dotenv
sha256: "9357883bdd153ab78cbf9ffa07656e336b8bbb2b5a3ca596b0b27e119f7c7d77"
url: "https://pub.dev"
source: hosted
version: "5.1.0"
flutter_gemini: flutter_gemini:
dependency: "direct main" dependency: "direct main"
description: description:
@ -180,18 +188,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: freezed_annotation name: freezed_annotation
sha256: f54946fdb1fa7b01f780841937b1a80783a20b393485f3f6cdf336fd6f4705f2 sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.4.2" version: "2.4.4"
http: http:
dependency: "direct main" dependency: "direct main"
description: description:
name: http name: http
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.1" version: "1.2.2"
http_parser: http_parser:
dependency: transitive dependency: transitive
description: description:
@ -208,6 +216,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.19.0" version: "0.19.0"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
json_annotation: json_annotation:
dependency: transitive dependency: transitive
description: description:
@ -300,10 +316,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: path_provider_android name: path_provider_android
sha256: bca87b0165ffd7cdb9cad8edd22d18d2201e886d9a9f19b4fb3452ea7df3a72a sha256: "30c5aa827a6ae95ce2853cdc5fe3971daaac00f6f081c419c013f7f57bff2f5e"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.2.6" version: "2.2.7"
path_provider_foundation: path_provider_foundation:
dependency: transitive dependency: transitive
description: description:
@ -332,10 +348,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: path_provider_windows name: path_provider_windows
sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.2.1" version: "2.3.0"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@ -396,10 +412,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_web name: shared_preferences_web
sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a" sha256: d762709c2bbe80626ecc819143013cc820fa49ca5e363620ee20a8b15a3e3daf
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.0" version: "2.2.1"
shared_preferences_windows: shared_preferences_windows:
dependency: transitive dependency: transitive
description: description:
@ -497,18 +513,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: web name: web
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.5.1" version: "1.0.0"
win32:
dependency: transitive
description:
name: win32
sha256: a79dbe579cb51ecd6d30b17e0cae4e0ea15e2c0e66f69ad4198f22a6789e94f4
url: "https://pub.dev"
source: hosted
version: "5.5.1"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:

View File

@ -42,6 +42,7 @@ dependencies:
path_provider: ^2.1.3 path_provider: ^2.1.3
path: ^1.9.0 path: ^1.9.0
flutter_gemini: ^2.0.4 flutter_gemini: ^2.0.4
flutter_dotenv: ^5.1.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
@ -68,6 +69,7 @@ flutter:
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
assets: assets:
- images/flutter.png - images/flutter.png
- .env
# - images/a_dot_ham.jpeg # - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see