showBadgePopup function

Future<void> showBadgePopup(
  1. BuildContext context,
  2. UserBadge badge
)

Implementation

Future<void> showBadgePopup(BuildContext context, UserBadge badge) {
  return showDialog<void>(
    context: context,
    builder: (context) {
      final l10n = AppLocalizations.of(context);
      return AlertDialog(
        icon: Icon(
          badgeIconFromKey(badge.badgeIconKey),
          size: 48,
          color: Colors.amber,
        ),
        title: Text(badge.badgeName ?? l10n.badgeEarned),
        content: badge.badgeDescription != null
            ? Text(badge.badgeDescription!, textAlign: TextAlign.center)
            : null,
        actions: [
          FilledButton(
            onPressed: () => Navigator.pop(context),
            child: Text(l10n.badgeAwesome),
          ),
        ],
        actionsAlignment: MainAxisAlignment.center,
      );
    },
  );
}