FriendInviteProgressCard constructor
FriendInviteProgressCard({
- Key? key,
- required int completedInvites,
- required int inviteGoal,
- required List<
FriendInviteMilestone> milestones, - required VoidCallback onInvite,
- required ValueChanged<
String> onClaimReward, - String? inviteCode,
- VoidCallback? onCopyInvite,
- String title = 'Invite Friends',
- String message = 'Invite friends and earn rewards together.',
- String inviteLabel = 'Invite Friends',
- String copyLabel = 'Copy Code',
- String? semanticLabel,
Implementation
FriendInviteProgressCard({
super.key,
required this.completedInvites,
required this.inviteGoal,
required this.milestones,
required this.onInvite,
required this.onClaimReward,
this.inviteCode,
this.onCopyInvite,
this.title = 'Invite Friends',
this.message = 'Invite friends and earn rewards together.',
this.inviteLabel = 'Invite Friends',
this.copyLabel = 'Copy Code',
this.semanticLabel,
}) {
if (completedInvites < 0 || inviteGoal <= 0) {
throw ArgumentError(
'completedInvites must be non-negative and inviteGoal positive',
);
}
if (title.trim().isEmpty || message.trim().isEmpty) {
throw ArgumentError('title and message must not be empty');
}
if (inviteLabel.trim().isEmpty || copyLabel.trim().isEmpty) {
throw ArgumentError('action labels must not be empty');
}
if (inviteCode != null && inviteCode!.trim().isEmpty) {
throw ArgumentError.value(
inviteCode,
'inviteCode',
'must not be empty when provided',
);
}
final ids = <String>{};
var previous = 0;
for (final milestone in milestones) {
if (milestone.id.trim().isEmpty || milestone.requiredInvites <= 0) {
throw ArgumentError.value(
milestone,
'milestones',
'id and positive invite target required',
);
}
if (!ids.add(milestone.id)) {
throw ArgumentError.value(
milestone.id,
'milestones',
'duplicate milestone id',
);
}
if (milestone.requiredInvites <= previous) {
throw ArgumentError.value(
milestone.requiredInvites,
'milestones',
'invite thresholds must be strictly increasing',
);
}
previous = milestone.requiredInvites;
}
}