This commit is contained in:
Tibor Bossanyi
2023-03-29 15:27:51 +02:00
parent 953753196b
commit 9311a888bc
5 changed files with 23 additions and 26 deletions
+13 -15
View File
@@ -1,9 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:workouttest_util/model/cache.dart';
import 'package:workouttest_util/service/customer_service.dart';
import 'package:workouttest_util/service/openai_service.dart';
void main() {
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: ".env");
runApp(const MyApp());
}
@@ -14,31 +17,30 @@ class MyApp extends StatefulWidget {
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _response = "";
@override
void initState() {
super.initState();
}
void _fetchData() async {
var api = OpenAIApi();
String response = await api.getOpenAICompletion("Who wrote the song 'yellow submarine'?");
//var api = OpenAIApi();
//String response = await api.getOpenAICompletion("Who wrote the song 'yellow submarine'?");
await CustomerApi().getCustomer(72);
String response = "OK";
setState(() {
_response = response;
_response = response;
});
}
@override
Widget build(BuildContext context) {
Cache().setLocalBaseUrl();
return MaterialApp(
home: Scaffold(
home: Scaffold(
appBar: AppBar(
title: const Text("Example"),
),
@@ -57,16 +59,12 @@ class _MyAppState extends State<MyApp> {
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
FloatingActionButton(
onPressed:() => {
_fetchData()
},
onPressed: () => {_fetchData()},
tooltip: 'Send question',
child: const Icon(Icons.ad_units),
),
],
)
],
),
),