buildDurationCard method

Widget buildDurationCard(
  1. UserModel user,
  2. bool isDark,
  3. BuildContext context
)

Duration Card

Implementation

Widget buildDurationCard(UserModel user, bool isDark, BuildContext context) {
  final statisticsController = StatisticsController();
  final localizations = AppLocalizations.of(context)!;

  return FutureBuilder<String?>(
    future: statisticsController.getDurationOfLastExercise(user.email, context),
    builder: (context, snapshot) {
      if (snapshot.connectionState == ConnectionState.waiting) {
        return _buildLoadingCard(icon: Icons.run_circle_outlined);
      }

      return _styledCard(
        icon: Icons.run_circle_outlined,
        iconColor: snapshot.hasData && snapshot.data != null
            ? tPrimaryColor
            : Colors.grey,
        title: localizations.tLastExerciseDuration,
        content: snapshot.data ?? localizations.tNoExercisesAvailable,
        isDark: isDark,
      );
    },
  );
}