build method
dynamic
build( - dynamic context,
- dynamic ref
)
Implementation
@override
Widget build(BuildContext context, WidgetRef ref) {
final myUserId = ref.watch(myUserIdStrProvider);
String? textMsg;
final msgType = message.metadata?['msgType'];
if (msgType == 'Joined') {
if (message.author.id == myUserId) {
textMsg = L10n.of(context).chatYouJoined;
} else if (message.author.firstName != null) {
textMsg =
L10n.of(context).chatJoinedDisplayName(message.author.firstName!);
} else {
textMsg = L10n.of(context).chatJoinedUserId(message.author.id);
}
} else if (msgType == 'InvitationAccepted') {
if (message.author.id == myUserId) {
textMsg = L10n.of(context).chatYouAcceptedInvite;
} else if (message.author.firstName != null) {
textMsg = L10n.of(context)
.chatInvitationAcceptedDisplayName(message.author.firstName!);
} else {
textMsg =
L10n.of(context).chatInvitationAcceptedUserId(message.author.id);
}
} else if (msgType == 'Invited') {
if (message.author.id == myUserId) {
textMsg = L10n.of(context).chatYouInvited;
} else if (message.author.firstName != null) {
textMsg =
L10n.of(context).chatInvitedDisplayName(message.author.firstName!);
} else {
textMsg = L10n.of(context).chatInvitedUserId(message.author.id);
}
} else {
textMsg = message.metadata?['body'] ?? '';
}
return Container(
padding: const EdgeInsets.only(left: 10, bottom: 5),
child: RichText(
text: TextSpan(
text: textMsg,
style: Theme.of(context).textTheme.labelSmall,
),
),
);
}