fitness_workout 1.0.0 copy "fitness_workout: ^1.0.0" to clipboard
fitness_workout: ^1.0.0 copied to clipboard

Fitness workout runner for Flutter. Strength (sets x reps x weight) and cardio (intervals/laps) controllers with persistable state, pluggable storage, drop-in dark-first widgets, editors, stats, PRs a [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:fitness_workout/fitness_workout.dart';

import 'finish_log.dart';
import 'home_page.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final workout = WorkoutRunner();
  final cardio = CardioRunner();
  await Future.wait([workout.tryAutoResume(), cardio.tryAutoResume()]);

  final log = FinishLog();
  workout.finished.listen(log.addWorkout);
  cardio.finished.listen(log.addCardio);

  runApp(ExampleApp(workoutRunner: workout, cardioRunner: cardio, log: log));
}

class ExampleApp extends StatefulWidget {
  final WorkoutRunner workoutRunner;
  final CardioRunner cardioRunner;
  final FinishLog log;

  const ExampleApp({
    super.key,
    required this.workoutRunner,
    required this.cardioRunner,
    required this.log,
  });

  @override
  State<ExampleApp> createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
  bool _themeIsDark = true;

  void _toggleTheme() => setState(() => _themeIsDark = !_themeIsDark);

  @override
  Widget build(BuildContext context) {
    final runnerTheme = _themeIsDark
        ? WorkoutRunnerThemeData.dark()
        : WorkoutRunnerThemeData.light();

    final materialTheme = ThemeData(
      useMaterial3: true,
      brightness: _themeIsDark ? Brightness.dark : Brightness.light,
      colorSchemeSeed: runnerTheme.accent,
      scaffoldBackgroundColor: runnerTheme.background,
      appBarTheme: AppBarTheme(
        backgroundColor: runnerTheme.background,
        foregroundColor: runnerTheme.textPrimary,
        elevation: 0,
      ),
      bottomNavigationBarTheme: BottomNavigationBarThemeData(
        backgroundColor: runnerTheme.surface,
        selectedItemColor: runnerTheme.accent,
        unselectedItemColor: runnerTheme.textMuted,
      ),
    );

    return MaterialApp(
      title: 'fitness_workout example',
      debugShowCheckedModeBanner: false,
      theme: materialTheme,
      home: RunnerScope(
        runner: widget.workoutRunner,
        child: CardioRunnerScope(
          runner: widget.cardioRunner,
          child: WorkoutRunnerTheme(
            data: runnerTheme,
            child: HomePage(
              workoutRunner: widget.workoutRunner,
              cardioRunner: widget.cardioRunner,
              log: widget.log,
              isDark: _themeIsDark,
              onToggleTheme: _toggleTheme,
            ),
          ),
        ),
      ),
    );
  }
}
0
likes
140
points
50
downloads
screenshot

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Fitness workout runner for Flutter. Strength (sets x reps x weight) and cardio (intervals/laps) controllers with persistable state, pluggable storage, drop-in dark-first widgets, editors, stats, PRs and a focus runner.

Repository (GitHub)
View/report issues

Topics

#fitness #workout #timer #health #widget

License

MIT (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on fitness_workout