timerun 0.8.3 copy "timerun: ^0.8.3" to clipboard
timerun: ^0.8.3 copied to clipboard

Is a timer library for Flutter that allows you to easily manage timers with customizable configurations. You can use this library to implement timers in your Flutter applications in a simple and flexible way.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:timerun/timerun.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late TimeRun timeRun;

  @override
  void initState() {
    print("FL -> se ejecuta");
    timeRun = TimeRun(
      series: 2,
      repetitions: 2,
      pauseSeries: 0,
      pauseRepeition: 5,
      time: 150,
      resetTimerOnResume: true,
      onChange: (p0) {
        print("STATE: $p0");
      },
      onFinish: () {
        print("FINISH");
      },
      onUpdate: (
        currentSeries,
        totalSeries,
        currentRepetition,
        totalRepetitions,
        currentSeconds,
        timePause,
        currentState,
      ) {
        print("currentSeries: $currentSeries");
        print("totalSeries: $totalSeries");
        print("currentRepetition: $currentRepetition");
        print("totalRepetitions: $totalRepetitions");
        print("currentSeconds: $currentSeconds");
        print("timePause: $timePause");
        print("currentState: $currentState");
      },
    );
    super.initState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> test() async {
    timeRun.play();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: timeRun.play,
                child: const Text('START'),
              ),
              const SizedBox(height: 5),
              ElevatedButton(
                onPressed: timeRun.pause,
                child: const Text('PAUSE'),
              ),
              const SizedBox(height: 5),
              ElevatedButton(
                onPressed: timeRun.resume,
                child: const Text('RESUME'),
              ),
              const SizedBox(height: 5),
              ElevatedButton(
                onPressed: timeRun.stop,
                child: const Text('STOP'),
              ),
              const SizedBox(height: 5),
              ElevatedButton(
                onPressed: () async => print(await timeRun.isPaused()),
                child: const Text('IS PAUSED ?'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
140
points
3
downloads

Publisher

unverified uploader

Weekly Downloads

Is a timer library for Flutter that allows you to easily manage timers with customizable configurations. You can use this library to implement timers in your Flutter applications in a simple and flexible way.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on timerun

Packages that implement timerun