From 708ce666fbec2c62638fa129ed20dad38768d36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sha=C3=AEhh?= Date: Sun, 19 May 2024 11:16:12 +0200 Subject: [PATCH] fix: naming --- .../providers/greencode_item_provider.dart | 30 +++++++++++++++++++ ...ll_greencode_item_list_provider_test.dart} | 0 2 files changed, 30 insertions(+) create mode 100644 lib/greencode/providers/greencode_item_provider.dart rename test/greencode/{greencode_item_list_provider_test.dart => all_greencode_item_list_provider_test.dart} (100%) diff --git a/lib/greencode/providers/greencode_item_provider.dart b/lib/greencode/providers/greencode_item_provider.dart new file mode 100644 index 000000000..2cecd0558 --- /dev/null +++ b/lib/greencode/providers/greencode_item_provider.dart @@ -0,0 +1,30 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:myecl/greencode/class/greencode_item.dart'; +import 'package:myecl/greencode/repositories/greencode_item_repository.dart'; +import 'package:myecl/tools/providers/single_notifier.dart'; + +class GreenCodeItemNotifier extends SingleNotifier { + final GreenCodeItemRepository greencodeItemRepository; + GreenCodeItemNotifier({required this.greencodeItemRepository}) + : super(const AsyncLoading()); + + void loadGreenCodeItembyQRCode(String qrCodeContent) async { + state = const AsyncLoading(); + final item = + await greencodeItemRepository.getGreenCodeItemByQR(qrCodeContent); + state = AsyncData(item); + } + + void setGreenCodeItem(GreenCodeItem i) { + state = AsyncData(i); + } +} + +final greenCodeItemProvider = + StateNotifierProvider>( + (ref) { + final greencodeItemRepository = ref.watch(greencodeItemRepositoryProvider); + return GreenCodeItemNotifier( + greencodeItemRepository: greencodeItemRepository, + ); +}); diff --git a/test/greencode/greencode_item_list_provider_test.dart b/test/greencode/all_greencode_item_list_provider_test.dart similarity index 100% rename from test/greencode/greencode_item_list_provider_test.dart rename to test/greencode/all_greencode_item_list_provider_test.dart