mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 22:44:21 +01:00
Integrate BenchmarkService into main.dart with Provider
This commit integrates the `BenchmarkService` into the main application setup through the `MultiProvider` in `main.dart`. The changes include: 1. Adding `BenchmarkService` to the list of service providers, allowing it to be accessible throughout the application via dependency injection. 2. Using `ProxyProvider` to ensure `BenchmarkService` gets the `RestApiUtility` instance as a dependency. 3. Modifying the `MyApp` class to fetch the `BenchmarkService` from the provider, making it ready for use in the application's lifecycle. This addition allows `BenchmarkService` to be centrally managed and readily available for any part of the application that requires benchmark-related functionalities.
This commit is contained in:
@@ -1,12 +1,16 @@
|
|||||||
import 'package:auto_gpt_flutter_client/viewmodels/api_settings_viewmodel.dart';
|
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'views/main_layout.dart';
|
import 'views/main_layout.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
|
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/chat_viewmodel.dart';
|
import 'package:auto_gpt_flutter_client/viewmodels/chat_viewmodel.dart';
|
||||||
|
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
|
||||||
|
import 'package:auto_gpt_flutter_client/viewmodels/api_settings_viewmodel.dart';
|
||||||
|
|
||||||
import 'package:auto_gpt_flutter_client/services/chat_service.dart';
|
import 'package:auto_gpt_flutter_client/services/chat_service.dart';
|
||||||
import 'package:auto_gpt_flutter_client/services/task_service.dart';
|
import 'package:auto_gpt_flutter_client/services/task_service.dart';
|
||||||
|
import 'package:auto_gpt_flutter_client/services/benchmark_service.dart';
|
||||||
|
|
||||||
import 'package:auto_gpt_flutter_client/utils/rest_api_utility.dart';
|
import 'package:auto_gpt_flutter_client/utils/rest_api_utility.dart';
|
||||||
|
|
||||||
// TODO: Update documentation throughout project for consistency
|
// TODO: Update documentation throughout project for consistency
|
||||||
@@ -25,6 +29,10 @@ void main() {
|
|||||||
update: (context, restApiUtility, taskService) =>
|
update: (context, restApiUtility, taskService) =>
|
||||||
TaskService(restApiUtility),
|
TaskService(restApiUtility),
|
||||||
),
|
),
|
||||||
|
ProxyProvider<RestApiUtility, BenchmarkService>(
|
||||||
|
update: (context, restApiUtility, taskService) =>
|
||||||
|
BenchmarkService(restApiUtility),
|
||||||
|
),
|
||||||
ChangeNotifierProxyProvider<RestApiUtility, ApiSettingsViewModel>(
|
ChangeNotifierProxyProvider<RestApiUtility, ApiSettingsViewModel>(
|
||||||
create: (context) => ApiSettingsViewModel(
|
create: (context) => ApiSettingsViewModel(
|
||||||
Provider.of<RestApiUtility>(context, listen: false)),
|
Provider.of<RestApiUtility>(context, listen: false)),
|
||||||
@@ -43,6 +51,8 @@ class MyApp extends StatelessWidget {
|
|||||||
// Fetch services from providers
|
// Fetch services from providers
|
||||||
final chatService = Provider.of<ChatService>(context, listen: false);
|
final chatService = Provider.of<ChatService>(context, listen: false);
|
||||||
final taskService = Provider.of<TaskService>(context, listen: false);
|
final taskService = Provider.of<TaskService>(context, listen: false);
|
||||||
|
final benchmarkService =
|
||||||
|
Provider.of<BenchmarkService>(context, listen: false);
|
||||||
taskService.loadDeletedTasks();
|
taskService.loadDeletedTasks();
|
||||||
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
@@ -57,7 +67,7 @@ class MyApp extends StatelessWidget {
|
|||||||
ChangeNotifierProvider(
|
ChangeNotifierProvider(
|
||||||
create: (context) => TaskViewModel(taskService)),
|
create: (context) => TaskViewModel(taskService)),
|
||||||
ChangeNotifierProvider(
|
ChangeNotifierProvider(
|
||||||
create: (context) => SkillTreeViewModel(),
|
create: (context) => SkillTreeViewModel(benchmarkService),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
child: MainLayout(),
|
child: MainLayout(),
|
||||||
|
|||||||
Reference in New Issue
Block a user