CollectionAlbumPanel constructor
CollectionAlbumPanel({
- Key? key,
- required String title,
- required List<
CollectionAlbumItem> items, - required ValueChanged<
String> onItemTap, - String? completionRewardLabel,
- VoidCallback? onViewReward,
- String emptyMessage = 'No collectibles in this album.',
Implementation
CollectionAlbumPanel({
super.key,
required this.title,
required this.items,
required this.onItemTap,
this.completionRewardLabel,
this.onViewReward,
this.emptyMessage = 'No collectibles in this album.',
}) {
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 item in items) {
if (item.id.trim().isEmpty || item.name.trim().isEmpty) {
throw ArgumentError.value(
item,
'items',
'id and name must not be empty',
);
}
if (!ids.add(item.id)) {
throw ArgumentError.value(
item.id,
'items',
'duplicate item id: ${item.id}',
);
}
if (item.ownedCount < 0 || item.requiredCount <= 0) {
throw ArgumentError.value(
item,
'items',
'ownedCount must be non-negative and requiredCount positive',
);
}
}
if (completionRewardLabel != null &&
completionRewardLabel!.trim().isEmpty) {
throw ArgumentError.value(
completionRewardLabel,
'completionRewardLabel',
'must not be empty when provided',
);
}
}