update perf
This commit is contained in:
@@ -10,8 +10,9 @@ part of 'promotions_provider.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
/// Promotions Provider
|
||||
///
|
||||
/// Fetches and caches the list of active promotions.
|
||||
/// Automatically handles loading, error, and data states.
|
||||
/// Uses the same data source as news articles to avoid duplicate API calls.
|
||||
/// Converts NewsArticle to Promotion entity for display in PromotionSlider.
|
||||
/// Limited to 5 items max.
|
||||
///
|
||||
/// Usage:
|
||||
/// ```dart
|
||||
@@ -25,13 +26,14 @@ part of 'promotions_provider.dart';
|
||||
/// );
|
||||
/// ```
|
||||
|
||||
@ProviderFor(PromotionsNotifier)
|
||||
const promotionsProvider = PromotionsNotifierProvider._();
|
||||
@ProviderFor(promotions)
|
||||
const promotionsProvider = PromotionsProvider._();
|
||||
|
||||
/// Promotions Provider
|
||||
///
|
||||
/// Fetches and caches the list of active promotions.
|
||||
/// Automatically handles loading, error, and data states.
|
||||
/// Uses the same data source as news articles to avoid duplicate API calls.
|
||||
/// Converts NewsArticle to Promotion entity for display in PromotionSlider.
|
||||
/// Limited to 5 items max.
|
||||
///
|
||||
/// Usage:
|
||||
/// ```dart
|
||||
@@ -44,12 +46,20 @@ const promotionsProvider = PromotionsNotifierProvider._();
|
||||
/// error: (error, stack) => ErrorWidget(error),
|
||||
/// );
|
||||
/// ```
|
||||
final class PromotionsNotifierProvider
|
||||
extends $AsyncNotifierProvider<PromotionsNotifier, List<Promotion>> {
|
||||
|
||||
final class PromotionsProvider
|
||||
extends
|
||||
$FunctionalProvider<
|
||||
AsyncValue<List<Promotion>>,
|
||||
List<Promotion>,
|
||||
FutureOr<List<Promotion>>
|
||||
>
|
||||
with $FutureModifier<List<Promotion>>, $FutureProvider<List<Promotion>> {
|
||||
/// Promotions Provider
|
||||
///
|
||||
/// Fetches and caches the list of active promotions.
|
||||
/// Automatically handles loading, error, and data states.
|
||||
/// Uses the same data source as news articles to avoid duplicate API calls.
|
||||
/// Converts NewsArticle to Promotion entity for display in PromotionSlider.
|
||||
/// Limited to 5 items max.
|
||||
///
|
||||
/// Usage:
|
||||
/// ```dart
|
||||
@@ -62,7 +72,7 @@ final class PromotionsNotifierProvider
|
||||
/// error: (error, stack) => ErrorWidget(error),
|
||||
/// );
|
||||
/// ```
|
||||
const PromotionsNotifierProvider._()
|
||||
const PromotionsProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
@@ -74,48 +84,18 @@ final class PromotionsNotifierProvider
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$promotionsNotifierHash();
|
||||
String debugGetCreateSourceHash() => _$promotionsHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
PromotionsNotifier create() => PromotionsNotifier();
|
||||
}
|
||||
$FutureProviderElement<List<Promotion>> $createElement(
|
||||
$ProviderPointer pointer,
|
||||
) => $FutureProviderElement(pointer);
|
||||
|
||||
String _$promotionsNotifierHash() =>
|
||||
r'3cd866c74ba11c6519e9b63521e1757ef117c7a9';
|
||||
|
||||
/// Promotions Provider
|
||||
///
|
||||
/// Fetches and caches the list of active promotions.
|
||||
/// Automatically handles loading, error, and data states.
|
||||
///
|
||||
/// Usage:
|
||||
/// ```dart
|
||||
/// // In a ConsumerWidget
|
||||
/// final promotionsAsync = ref.watch(promotionsProvider);
|
||||
///
|
||||
/// promotionsAsync.when(
|
||||
/// data: (promotions) => PromotionSlider(promotions: promotions),
|
||||
/// loading: () => CircularProgressIndicator(),
|
||||
/// error: (error, stack) => ErrorWidget(error),
|
||||
/// );
|
||||
/// ```
|
||||
|
||||
abstract class _$PromotionsNotifier extends $AsyncNotifier<List<Promotion>> {
|
||||
FutureOr<List<Promotion>> build();
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build();
|
||||
final ref = this.ref as $Ref<AsyncValue<List<Promotion>>, List<Promotion>>;
|
||||
final element =
|
||||
ref.element
|
||||
as $ClassProviderElement<
|
||||
AnyNotifier<AsyncValue<List<Promotion>>, List<Promotion>>,
|
||||
AsyncValue<List<Promotion>>,
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
FutureOr<List<Promotion>> create(Ref ref) {
|
||||
return promotions(ref);
|
||||
}
|
||||
}
|
||||
|
||||
String _$promotionsHash() => r'2eac0298d2b84ad5cc50faa6b8a015dbf7b7a1d3';
|
||||
|
||||
Reference in New Issue
Block a user