From fccf4f08325eb313ae6b8535ca3e7d5e327175e7 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 17 Jul 2024 22:49:47 +0200 Subject: [PATCH] first test ok --- covas_mobile/.gitignore | 2 + covas_mobile/lib/pages/Camera.dart | 3 - .../lib/pages/DisplayPictureScreen.dart | 11 +-- covas_mobile/pubspec.lock | 68 +++++++++++-------- covas_mobile/pubspec.yaml | 2 + 5 files changed, 48 insertions(+), 38 deletions(-) diff --git a/covas_mobile/.gitignore b/covas_mobile/.gitignore index a8e938c..e158b41 100644 --- a/covas_mobile/.gitignore +++ b/covas_mobile/.gitignore @@ -45,3 +45,5 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release + +.env \ No newline at end of file diff --git a/covas_mobile/lib/pages/Camera.dart b/covas_mobile/lib/pages/Camera.dart index f7cba64..a1b93c3 100644 --- a/covas_mobile/lib/pages/Camera.dart +++ b/covas_mobile/lib/pages/Camera.dart @@ -4,7 +4,6 @@ import 'dart:io'; import 'DisplayPictureScreen.dart'; import 'package:camera/camera.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_gemini/flutter_gemini.dart'; Future main() async { // Ensure that plugin services are initialized so that `availableCameras()` @@ -14,8 +13,6 @@ Future main() async { // Obtain a list of the available cameras on the device. final cameras = await availableCameras(); - Gemini.init(apiKey: 'AIzaSyAt1LQIV_hwJQF56sXjb4oxEZEC0wI3PKg'); - // Get a specific camera from the list of available cameras. final firstCamera = cameras.first; diff --git a/covas_mobile/lib/pages/DisplayPictureScreen.dart b/covas_mobile/lib/pages/DisplayPictureScreen.dart index ea38a63..adc9c6e 100644 --- a/covas_mobile/lib/pages/DisplayPictureScreen.dart +++ b/covas_mobile/lib/pages/DisplayPictureScreen.dart @@ -1,11 +1,10 @@ import 'package:flutter/material.dart'; import 'dart:io'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_gemini/flutter_gemini.dart'; void main() { - Gemini.init(apiKey: 'AIzaSyAt1LQIV_hwJQF56sXjb4oxEZEC0wI3PKg'); - runApp(MyApp()); } @@ -54,8 +53,10 @@ class DisplayPictureScreenState extends State { } Future _getEventInfosFromImage() async { - Gemini.init(apiKey: 'AIzaSyAt1LQIV_hwJQF56sXjb4oxEZEC0wI3PKg'); - final gemini = Gemini.instance; + await dotenv.load(); + + final gemini = Gemini.init( + apiKey: dotenv.env['GEMINI_API_KEY']!, enableDebugging: true); final file = File(widget.imagePath); @@ -63,7 +64,7 @@ class DisplayPictureScreenState extends State { .textAndImage( text: "What is this picture ?", images: [file.readAsBytesSync()]) .then((value) => print(value?.content?.parts?.last.text ?? '')) - .catchError((e) => print(e)); + .catchError((e) => print("problem gemini : ${e}")); } @override diff --git a/covas_mobile/pubspec.lock b/covas_mobile/pubspec.lock index b419436..5c8ffbb 100644 --- a/covas_mobile/pubspec.lock +++ b/covas_mobile/pubspec.lock @@ -29,34 +29,34 @@ packages: dependency: transitive description: name: camera_android_camerax - sha256: c6b6a637fc72471dc82c72d06b1a7edd8390477d8dbe026fed6c2f34f04f6d06 + sha256: "7c03940cb8c92eb5b184952674a07cc4a73c6ba2b3568aad70255ad4cb913660" url: "https://pub.dev" source: hosted - version: "0.6.6" + version: "0.6.7+1" camera_avfoundation: dependency: transitive description: name: camera_avfoundation - sha256: "7d021e8cd30d9b71b8b92b4ad669e80af432d722d18d6aac338572754a786c15" + sha256: b5093a82537b64bb88d4244f8e00b5ba69e822a5994f47b31d11400e1db975e5 url: "https://pub.dev" source: hosted - version: "0.9.16" + version: "0.9.17+1" camera_platform_interface: dependency: transitive description: name: camera_platform_interface - sha256: a250314a48ea337b35909a4c9d5416a208d736dcb01d0b02c6af122be66660b0 + sha256: b3ede1f171532e0d83111fe0980b46d17f1aa9788a07a2fbed07366bbdbb9061 url: "https://pub.dev" source: hosted - version: "2.7.4" + version: "2.8.0" camera_web: dependency: "direct main" description: name: camera_web - sha256: "9e9aba2fbab77ce2472924196ff8ac4dd8f9126c4f9a3096171cd1d870d6b26c" + sha256: b9235ec0a2ce949daec546f1f3d86f05c3921ed31c7d9ab6b7c03214d152fc2d url: "https://pub.dev" source: hosted - version: "0.3.3" + version: "0.3.4" characters: dependency: transitive description: @@ -85,10 +85,10 @@ packages: dependency: transitive description: name: cross_file - sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32" + sha256: "2f9d2cbccb76127ba28528cb3ae2c2326a122446a83de5a056aaa3880d3882c5" url: "https://pub.dev" source: hosted - version: "0.3.4+1" + version: "0.3.3+7" cupertino_icons: dependency: "direct main" description: @@ -142,6 +142,14 @@ packages: description: flutter source: sdk 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: dependency: "direct main" description: @@ -180,18 +188,18 @@ packages: dependency: transitive description: name: freezed_annotation - sha256: f54946fdb1fa7b01f780841937b1a80783a20b393485f3f6cdf336fd6f4705f2 + sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "2.4.4" http: dependency: "direct main" description: name: http - sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" + sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.2" http_parser: dependency: transitive description: @@ -208,6 +216,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.19.0" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" json_annotation: dependency: transitive description: @@ -300,10 +316,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: bca87b0165ffd7cdb9cad8edd22d18d2201e886d9a9f19b4fb3452ea7df3a72a + sha256: "30c5aa827a6ae95ce2853cdc5fe3971daaac00f6f081c419c013f7f57bff2f5e" url: "https://pub.dev" source: hosted - version: "2.2.6" + version: "2.2.7" path_provider_foundation: dependency: transitive description: @@ -332,10 +348,10 @@ packages: dependency: transitive description: name: path_provider_windows - sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "2.3.0" platform: dependency: transitive description: @@ -396,10 +412,10 @@ packages: dependency: transitive description: name: shared_preferences_web - sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a" + sha256: d762709c2bbe80626ecc819143013cc820fa49ca5e363620ee20a8b15a3e3daf url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.2.1" shared_preferences_windows: dependency: transitive description: @@ -497,18 +513,10 @@ packages: dependency: transitive description: name: web - sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062 url: "https://pub.dev" source: hosted - version: "0.5.1" - win32: - dependency: transitive - description: - name: win32 - sha256: a79dbe579cb51ecd6d30b17e0cae4e0ea15e2c0e66f69ad4198f22a6789e94f4 - url: "https://pub.dev" - source: hosted - version: "5.5.1" + version: "1.0.0" xdg_directories: dependency: transitive description: diff --git a/covas_mobile/pubspec.yaml b/covas_mobile/pubspec.yaml index 7551e9a..25fb5de 100644 --- a/covas_mobile/pubspec.yaml +++ b/covas_mobile/pubspec.yaml @@ -42,6 +42,7 @@ dependencies: path_provider: ^2.1.3 path: ^1.9.0 flutter_gemini: ^2.0.4 + flutter_dotenv: ^5.1.0 dev_dependencies: flutter_test: @@ -68,6 +69,7 @@ flutter: # To add assets to your application, add an assets section, like this: assets: - images/flutter.png + - .env # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see