A Flutter package for creating a high-intensity interval training (HIIT) timer with background service capabilities. Originally created for OpenHIIT.
Add background_hiit_timer to your pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
background_hiit_timer: ^1.0.0Import background_hiit_timer in your Dart file:
import 'package:background_hiit_timer/background_hiit_timer.dart';-
Ensure that your app is properly configured to handle background execution on both Android and iOS platforms. Refer to flutter_background_service for details.
-
Define a set of intervals:
final List<IntervalType> intervals = [
IntervalType(
id: "0",
workoutId: "1",
time: 10, // in seconds
name: "Get ready",
color: 0,
intervalIndex: 0,
startSound: "",
halfwaySound: "",
countdownSound: "countdown-beep",
endSound: ""),
...
IntervalType(
id: "4",
workoutId: "1",
time: 10, // in seconds
name: "Cooldown",
color: 0,
intervalIndex: 4,
startSound: "long-rest-beep",
countdownSound: "countdown-beep",
endSound: "horn",
halfwaySound: ""),
];
- Define a controller:
final CountdownController _controller = CountdownController(autoStart: true);
- Create a
Countdownwidget and configure it with your interval settings:
Countdown(
controller: _controller,
intervals: intervals,
onFinished: () {},
build: (_, TimerState timerState) {
Text(timerState.currentMicroSeconds.toString())
}
)Check out the example directory in this repository for a complete example of how to use background_hiit_timer in a Flutter app.
For more advanced information, view the advanced configuration documentation.
View the contributing documentation. If contributing code changes, please checkout the testing documentation.
When contributing, please keep the Code of Conduct in mind.
This package is inspired by the timer_count_down package by Dizoft Team.
Shoutout to flutter_background_service for making the background timer possible.
MIT License. See LICENSE for details.
