build method

  1. @override
dynamic build(
  1. dynamic context,
  2. dynamic ref
)

Implementation

@override
Widget build(BuildContext context, WidgetRef ref) {
  final title =
      ref.watch(roomDisplayNameProvider(roomId)).valueOrNull ?? roomId;
  final roomAvatar = ref.watch(roomAvatarInfoProvider(roomId));
  final parentBadges =
      ref.watch(parentAvatarInfosProvider(roomId)).valueOrNull;

  final avatar = ActerAvatar(
    options: AvatarOptions(
      roomAvatar,
      parentBadges: parentBadges,
      size: 45,
      badgesSize: 45 / 2,
    ),
  );

  return Card(
    margin: const EdgeInsets.symmetric(vertical: 5),
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(6),
    ),
    child: ListTile(
      title: Text(
        title,
        style: Theme.of(context).textTheme.titleSmall,
      ),
      subtitle: FutureBuilder(
        future: ref.watch(membersIdsProvider(roomId).future),
        builder: (context, snapshot) {
          final memberCount = snapshot.data?.length ?? 0;
          return Text(
            L10n.of(context).countsMembers(memberCount),
            style: Theme.of(context).textTheme.bodySmall,
          );
        },
      ),
      leading: avatar,
      onTap: () => onChanged(!isSelected),
      trailing: Checkbox(
        value: isSelected,
        onChanged: onChanged,
      ),
    ),
  );
}