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

It is a simple pausable countdown timer.

example/lib/main.dart

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

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Timer Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Timer Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'Timer that stops when tapped.',
              style: TextStyle(fontSize: 24),
            ),
            Container(
              margin: const EdgeInsets.all(50),
              child: CountdownTimer(
                seconds: 1000,
                textStyle:
                    const TextStyle(fontSize: 100, fontWeight: FontWeight.bold),
                pauseAction: () {
                  showDialog(
                    context: context,
                    builder: (BuildContext context) => AlertDialog(
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(15),
                      ),
                      title: const Text(
                        'pause!',
                        textAlign: TextAlign.center,
                      ),
                    ),
                  );
                },
                restartAction: () {
                  showDialog(
                    context: context,
                    builder: (BuildContext context) => AlertDialog(
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(15),
                      ),
                      title: const Text(
                        'restart!',
                        textAlign: TextAlign.center,
                      ),
                    ),
                  );
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
2
likes
130
pub points
41%
popularity

Publisher

unverified uploader

It is a simple pausable countdown timer.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, flutter_hooks

More

Packages that depend on flutter_pausable_countdown_timer