From 3ad8eb9033b48e3a718ef8d06011da295372ee0f Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sun, 7 Jul 2024 10:53:33 +0200 Subject: [PATCH] add ai init gemini --- covas_mobile/lib/pages/Camera.dart | 18 +------ .../lib/pages/DisplayPictureScreen.dart | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 17 deletions(-) create mode 100644 covas_mobile/lib/pages/DisplayPictureScreen.dart diff --git a/covas_mobile/lib/pages/Camera.dart b/covas_mobile/lib/pages/Camera.dart index 9ce3c6b..f7cba64 100644 --- a/covas_mobile/lib/pages/Camera.dart +++ b/covas_mobile/lib/pages/Camera.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:io'; +import 'DisplayPictureScreen.dart'; import 'package:camera/camera.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gemini/flutter_gemini.dart'; @@ -126,20 +127,3 @@ class CameraState extends State { ); } } - -// A widget that displays the picture taken by the user. -class DisplayPictureScreen extends StatelessWidget { - final String imagePath; - - const DisplayPictureScreen({super.key, required this.imagePath}); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: const Text('Display the Picture')), - // The image is stored as a file on the device. Use the `Image.file` - // constructor with the given path to display the image. - body: Image.file(File(imagePath)), - ); - } -} diff --git a/covas_mobile/lib/pages/DisplayPictureScreen.dart b/covas_mobile/lib/pages/DisplayPictureScreen.dart new file mode 100644 index 0000000..e3b44e2 --- /dev/null +++ b/covas_mobile/lib/pages/DisplayPictureScreen.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; +import 'dart:io'; + +import 'package:flutter_gemini/flutter_gemini.dart'; + +void main() { + Gemini.init(apiKey: 'AIzaSyAt1LQIV_hwJQF56sXjb4oxEZEC0wI3PKg'); + + runApp(MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + + // This widget is the root of your application. + + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + // This is the theme of your application. + // + // Try running your application with "flutter run". You'll see the + // application has a blue toolbar. Then, without quitting the app, try + // changing the primarySwatch below to Colors.green and then invoke + // "hot reload" (press "r" in the console where you ran "flutter run", + // or simply save your changes to "hot reload" in a Flutter IDE). + // Notice that the counter didn't reset back to zero; the application + // is not restarted. + primarySwatch: Colors.blue, + ), + ); + } +} + +// A widget that displays the picture taken by the user. +class DisplayPictureScreen extends StatelessWidget { + final String imagePath; + + const DisplayPictureScreen({super.key, required this.imagePath}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('Display the Picture')), + // The image is stored as a file on the device. Use the `Image.file` + // constructor with the given path to display the image. + body: Image.file(File(imagePath)), + ); + } +}