update products
This commit is contained in:
43
lib/features/products/data/providers/product_providers.dart
Normal file
43
lib/features/products/data/providers/product_providers.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:hive_ce/hive.dart';
|
||||
import '../datasources/product_local_datasource.dart';
|
||||
import '../datasources/product_remote_datasource.dart';
|
||||
import '../repositories/product_repository_impl.dart';
|
||||
import '../models/product_model.dart';
|
||||
import '../../domain/repositories/product_repository.dart';
|
||||
import '../../../../core/providers/providers.dart';
|
||||
import '../../../../core/constants/storage_constants.dart';
|
||||
|
||||
part 'product_providers.g.dart';
|
||||
|
||||
/// Provider for product Hive box
|
||||
@riverpod
|
||||
Box<ProductModel> productBox(Ref ref) {
|
||||
return Hive.box<ProductModel>(StorageConstants.productsBox);
|
||||
}
|
||||
|
||||
/// Provider for product local data source
|
||||
@riverpod
|
||||
ProductLocalDataSource productLocalDataSource(Ref ref) {
|
||||
final box = ref.watch(productBoxProvider);
|
||||
return ProductLocalDataSourceImpl(box);
|
||||
}
|
||||
|
||||
/// Provider for product remote data source
|
||||
@riverpod
|
||||
ProductRemoteDataSource productRemoteDataSource(Ref ref) {
|
||||
final dioClient = ref.watch(dioClientProvider);
|
||||
return ProductRemoteDataSourceImpl(dioClient);
|
||||
}
|
||||
|
||||
/// Provider for product repository
|
||||
@riverpod
|
||||
ProductRepository productRepository(Ref ref) {
|
||||
final localDataSource = ref.watch(productLocalDataSourceProvider);
|
||||
final remoteDataSource = ref.watch(productRemoteDataSourceProvider);
|
||||
|
||||
return ProductRepositoryImpl(
|
||||
localDataSource: localDataSource,
|
||||
remoteDataSource: remoteDataSource,
|
||||
);
|
||||
}
|
||||
219
lib/features/products/data/providers/product_providers.g.dart
Normal file
219
lib/features/products/data/providers/product_providers.g.dart
Normal file
@@ -0,0 +1,219 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'product_providers.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
/// Provider for product Hive box
|
||||
|
||||
@ProviderFor(productBox)
|
||||
const productBoxProvider = ProductBoxProvider._();
|
||||
|
||||
/// Provider for product Hive box
|
||||
|
||||
final class ProductBoxProvider
|
||||
extends
|
||||
$FunctionalProvider<
|
||||
Box<ProductModel>,
|
||||
Box<ProductModel>,
|
||||
Box<ProductModel>
|
||||
>
|
||||
with $Provider<Box<ProductModel>> {
|
||||
/// Provider for product Hive box
|
||||
const ProductBoxProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'productBoxProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$productBoxHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$ProviderElement<Box<ProductModel>> $createElement(
|
||||
$ProviderPointer pointer,
|
||||
) => $ProviderElement(pointer);
|
||||
|
||||
@override
|
||||
Box<ProductModel> create(Ref ref) {
|
||||
return productBox(ref);
|
||||
}
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(Box<ProductModel> value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<Box<ProductModel>>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$productBoxHash() => r'68cd21ea28cfc716f34daef17849a0393cdb2b80';
|
||||
|
||||
/// Provider for product local data source
|
||||
|
||||
@ProviderFor(productLocalDataSource)
|
||||
const productLocalDataSourceProvider = ProductLocalDataSourceProvider._();
|
||||
|
||||
/// Provider for product local data source
|
||||
|
||||
final class ProductLocalDataSourceProvider
|
||||
extends
|
||||
$FunctionalProvider<
|
||||
ProductLocalDataSource,
|
||||
ProductLocalDataSource,
|
||||
ProductLocalDataSource
|
||||
>
|
||||
with $Provider<ProductLocalDataSource> {
|
||||
/// Provider for product local data source
|
||||
const ProductLocalDataSourceProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'productLocalDataSourceProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$productLocalDataSourceHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$ProviderElement<ProductLocalDataSource> $createElement(
|
||||
$ProviderPointer pointer,
|
||||
) => $ProviderElement(pointer);
|
||||
|
||||
@override
|
||||
ProductLocalDataSource create(Ref ref) {
|
||||
return productLocalDataSource(ref);
|
||||
}
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(ProductLocalDataSource value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<ProductLocalDataSource>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$productLocalDataSourceHash() =>
|
||||
r'ef4673055777e8dc8a8419a80548b319789d99f9';
|
||||
|
||||
/// Provider for product remote data source
|
||||
|
||||
@ProviderFor(productRemoteDataSource)
|
||||
const productRemoteDataSourceProvider = ProductRemoteDataSourceProvider._();
|
||||
|
||||
/// Provider for product remote data source
|
||||
|
||||
final class ProductRemoteDataSourceProvider
|
||||
extends
|
||||
$FunctionalProvider<
|
||||
ProductRemoteDataSource,
|
||||
ProductRemoteDataSource,
|
||||
ProductRemoteDataSource
|
||||
>
|
||||
with $Provider<ProductRemoteDataSource> {
|
||||
/// Provider for product remote data source
|
||||
const ProductRemoteDataSourceProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'productRemoteDataSourceProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$productRemoteDataSourceHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$ProviderElement<ProductRemoteDataSource> $createElement(
|
||||
$ProviderPointer pointer,
|
||||
) => $ProviderElement(pointer);
|
||||
|
||||
@override
|
||||
ProductRemoteDataSource create(Ref ref) {
|
||||
return productRemoteDataSource(ref);
|
||||
}
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(ProductRemoteDataSource value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<ProductRemoteDataSource>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$productRemoteDataSourceHash() =>
|
||||
r'954798907bb0c9baade27b84eaba612a5dec8f68';
|
||||
|
||||
/// Provider for product repository
|
||||
|
||||
@ProviderFor(productRepository)
|
||||
const productRepositoryProvider = ProductRepositoryProvider._();
|
||||
|
||||
/// Provider for product repository
|
||||
|
||||
final class ProductRepositoryProvider
|
||||
extends
|
||||
$FunctionalProvider<
|
||||
ProductRepository,
|
||||
ProductRepository,
|
||||
ProductRepository
|
||||
>
|
||||
with $Provider<ProductRepository> {
|
||||
/// Provider for product repository
|
||||
const ProductRepositoryProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'productRepositoryProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$productRepositoryHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$ProviderElement<ProductRepository> $createElement(
|
||||
$ProviderPointer pointer,
|
||||
) => $ProviderElement(pointer);
|
||||
|
||||
@override
|
||||
ProductRepository create(Ref ref) {
|
||||
return productRepository(ref);
|
||||
}
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(ProductRepository value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<ProductRepository>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$productRepositoryHash() => r'7c5c5b274ce459add6449c29be822ea04503d3dc';
|
||||
Reference in New Issue
Block a user