background_hiit_timer
A Flutter package for creating a high-intensity interval training (HIIT) timer with background service capabilities. Originally created for OpenHIIT.
Table of Contents
Installation
Add background_hiit_timer to your pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
background_hiit_timer: ^1.0.0
Basic Usage
Import 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())
}
)
Example Usage
Check out the example directory in this repository for a complete example of how to use background_hiit_timer in a Flutter app.
Advanced Configuration
For more advanced information, view the advanced configuration documentation.
Contributing
View the contributing documentation. If contributing code changes, please checkout the testing documentation.
Code of Conduct
When contributing, please keep the Code of Conduct in mind.
Credits
This package is inspired by the timer_count_down package by Dizoft Team.
Shoutout to flutter_background_service for making the background timer possible.
License
MIT License. See LICENSE for details.