getParticipantString method
Implementation
String getParticipantString(List<String> participants, WidgetRef ref) {
return ref.watch(userDataProvider).maybeWhen(
orElse: () => "",
data: (users) {
String firstUser;
String secondUser;
if (participants.isEmpty) {
return "0 ${t.participant.xParticipants}";
}
firstUser =
users[participants.first]?.displayName?.split(' ')[0] ?? "";
if (participants.length == 1) {
return "$firstUser ${t.participant.goes}";
}
secondUser =
users[participants.last]?.displayName?.split(' ')[0] ?? "";
if (participants.length == 2) {
return "$firstUser ${t.generics.and} $secondUser ${t.participant.andOthers(count: 0)}";
}
return "$firstUser, $secondUser ${t.participant.andOthers(count: participants.length - 2)}";
},
);
}