display_timer 1.0.1 display_timer: ^1.0.1 copied to clipboard
A highly customizible Flutter widget that fires a timer and update it's own ui to reflect the value of the current timer
The display_timer is a handy widget when you want to display a ticking timer on the screen. The Widget handles the ticking and provides a simple Widget builder, so you can customize the widget to your preferences.
Features #
DisplayTimerBuilder is a WidgetBuilder that receives all the necessary information to display the timer. It receives the Hours, Minutes and Seconds. You can get this information and display whatever your needs.
Usage #
To see a working example of the package, please refer to the example folder.
The above example shows a basic usage of the package. See that the displayTimerBuilder receives the values String. So you can freely use them as your wish. The package also offers a onTimerEnd callback that will be executed whenever the timer ends.
The above example creates a 10 second timer and prints the 'Timer has ended. Do something' String whenever the timer ends.
class DisplayTimerTest extends StatelessWidget {
const DisplayTimerTest({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: DisplayTimer(
timerDuration: const Duration(seconds: 10),
displayTimerBuilder: (String hours, String minutes, String seconds) => Text(
'$hours:$minutes:$seconds',
),
onTimerEnd: () async {
print('Timer has ended. Do something');
},
),
),
);
}
}