WidgetCallbacks class
Everything a host app must inject so the widget catalog can stay backend-agnostic: navigation, data fetching and auth/cart state all come from here instead of any global singleton (§4 of the widget catalog doc).
Constructors
-
WidgetCallbacks({required void onAction(WidgetAction action), required Future<
List< fetchProducts(ProductQuery query), Future<ProductCardData> >List< fetchSlides(dynamic id)?, Future<SlideItem> >List< fetchVideos(dynamic id)?, Future<VideoItem> >String?> fetchModal(dynamic id)?, Future<ProductCardData?> fetchProductDetail(dynamic id)?, bool isLoggedIn()?, void onRequireAuth()?, Future<bool> onToggleFavorite(ProductCardData product)?, Future<void> onAddToCart(ProductCardData product, ProductVariant? variant, int quantity)?, List<ProductCardData> visitedProducts()?, Widget imageErrorBuilder()?, String formatPrice(num amount, String currency)?, Widget productCardBuilder(ProductCardData data)?}) -
const
Properties
-
fetchModal
→ Future<
String?> Function(dynamic id)? -
Fetches popup content for a
type: "modal"tap target.final -
fetchProductDetail
→ Future<
ProductCardData?> Function(dynamic id)? -
Fetches full product detail (e.g. richer variant data) for a
type: "product"tap target.final -
fetchProducts
→ Future<
List< Function(ProductQuery query)ProductCardData> > -
Fetches the product list backing CAROUSEL/GRID/PRODUCTCARD/FLASHSALE/
MIXEDCAROUSEL.
final
-
fetchSlides
→ Future<
List< Function(dynamic id)?SlideItem> > -
Fetches slide items by id for SLIDER/IMAGECAROUSEL.
final
-
fetchVideos
→ Future<
List< Function(dynamic id)?VideoItem> > -
Fetches videos by id for VIDEOLIST.
final
- formatPrice → String Function(num amount, String currency)?
-
Optional override for rendering a price as text (e.g. locale-aware
thousands separators, or a currency other than the package's built-in
USD/EUR/RUB/TRY symbols). Falls back to each card's default
"<amount> <symbol>"formatting when unset.final - hashCode → int
-
The hash code for this object.
no setterinherited
- imageErrorBuilder → Widget Function()?
-
Optional override for the placeholder shown when a network image fails
to load.
final
- isLoggedIn → bool Function()?
-
Whether the current user is logged in. Drives price-hiding on
ProductCardData and hiding LOGIN/REGISTER banners.
final
- onAction → void Function(WidgetAction action)
-
Resolves any tap/navigation target produced from a widget's
type+id/urlcontract.final -
onAddToCart
→ Future<
void> Function(ProductCardData product, ProductVariant? variant, int quantity)? -
Adds a product (optionally with a chosen variant and quantity) to the
cart.
final
- onRequireAuth → void Function()?
-
Called when an action that needs auth (e.g. viewing a hidden price) is
taken while logged out.
final
-
onToggleFavorite
→ Future<
bool> Function(ProductCardData product)? -
Toggles a product's favorite state; returns the new state.
final
- productCardBuilder → Widget Function(ProductCardData data)?
-
Optional full override for a product card's UI: when set, CAROUSEL,
PRODUCTCARD and FLASHSALE render this instead of RichProductCard (GRID
keeps its own
OldProductCarddesign either way). Lets a host app replace the card entirely without forking the package.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
visitedProducts
→ List<
ProductCardData> Function()? -
Returns the locally-tracked "recently visited" product list, for
VISITEDPRODUCTS.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited