Skip to content

Commit

Permalink
fix: naming
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumetavernier committed May 19, 2024
1 parent 61d1da8 commit 708ce66
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/greencode/providers/greencode_item_provider.dart
Original file line number Diff line number Diff line change
@@ -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<GreenCodeItem> {
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<GreenCodeItemNotifier, AsyncValue<GreenCodeItem>>(
(ref) {
final greencodeItemRepository = ref.watch(greencodeItemRepositoryProvider);
return GreenCodeItemNotifier(
greencodeItemRepository: greencodeItemRepository,
);
});

0 comments on commit 708ce66

Please sign in to comment.