DailyOfferStack constructor
DailyOfferStack({
- Key? key,
- required List<
DailyOffer> offers, - required ValueChanged<
String> onOpen, - String title = 'Daily Offers',
- String emptyMessage = 'No offers available right now.',
- String? semanticLabel,
Implementation
DailyOfferStack({
super.key,
required this.offers,
required this.onOpen,
this.title = 'Daily Offers',
this.emptyMessage = 'No offers available right now.',
this.semanticLabel,
}) {
if (title.trim().isEmpty) {
throw ArgumentError.value(title, 'title', 'must not be empty');
}
if (emptyMessage.trim().isEmpty) {
throw ArgumentError.value(
emptyMessage,
'emptyMessage',
'must not be empty',
);
}
final ids = <String>{};
for (final offer in offers) {
if (offer.id.trim().isEmpty) {
throw ArgumentError.value(offer.id, 'offer.id', 'must not be empty');
}
if (!ids.add(offer.id)) {
throw ArgumentError.value(
offer.id,
'offers',
'duplicate offer id: ${offer.id}',
);
}
if (offer.title.trim().isEmpty) {
throw ArgumentError.value(
offer.title,
'offer.title',
'must not be empty',
);
}
if (offer.priceLabel.trim().isEmpty) {
throw ArgumentError.value(
offer.priceLabel,
'offer.priceLabel',
'must not be empty',
);
}
}
}