build method

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

Implementation

@override
Widget build(BuildContext context, WidgetRef ref) {
  final avatarLoader = ref.watch(searchItemProfileData(item));
  final topic = item.topic();

  return Card(
    child: Column(
      mainAxisSize: MainAxisSize.min,
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Flexible(
          child: Padding(
            padding: const EdgeInsets.symmetric(vertical: 5),
            child: ListTile(
              onTap: () => onSelected(item),
              leading: avatarLoader.when(
                data: (avatar) => ActerAvatar(
                  options: AvatarOptions(avatar),
                ),
                error: (e, s) {
                  _log.severe('Failed to load avatar info', e, s);
                  return fallbackAvatar();
                },
                loading: fallbackAvatar,
              ),
              title: Text(
                item.name() ?? L10n.of(context).noDisplayName,
                style: Theme.of(context).textTheme.labelLarge,
                softWrap: false,
              ),
              subtitle: Text(
                L10n.of(context).countsMembers(item.numJoinedMembers()),
                style: Theme.of(context).textTheme.labelSmall,
                softWrap: false,
              ),
              trailing: _JoinBtn(
                item: item,
                onSelected: onSelected,
              ),
            ),
          ),
        ),
        if (topic != null)
          Flexible(
            child: Padding(
              padding: const EdgeInsets.symmetric(
                horizontal: 12,
                vertical: 8,
              ),
              child: Text(
                topic,
                style: Theme.of(context).textTheme.labelMedium,
                maxLines: 5,
                overflow: TextOverflow.ellipsis,
              ),
            ),
          ),
      ],
    ),
  );
}