timer_count_down 1.0.3 copy "timer_count_down: ^1.0.3" to clipboard
timer_count_down: ^1.0.3 copied to clipboard

outdated

Simple CountDown timer. Using for create a simple timer. It's pure all

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:timer_count_down/timer_controller.dart';

import 'package:timer_count_down/timer_count_down.dart';

void main() => runApp(MyApp());

///
/// Test app
///
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Countdown Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(
        title: 'Flutter Demo Countdown',
      ),
    );
  }
}

///
/// Home page
///
class MyHomePage extends StatefulWidget {
  ///
  /// AppBar title
  ///
  final String title;

  MyHomePage({
    Key key,
    this.title,
  }) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

///
/// Page state
///
class _MyHomePageState extends State<MyHomePage> {
  final CountdownController controller = CountdownController();

  bool _isPause = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          widget.title,
        ),
      ),
      body: Center(
        child: Countdown(
          controller: controller,
          seconds: 20,
          build: (_, double time) => Text(time.toString()),
          interval: Duration(
            milliseconds: 100,
          ),
          onFinished: () {
            print('Timer is done!');
          },
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(
          _isPause ? Icons.pause : Icons.play_arrow,
        ),
        onPressed: () {
          if (_isPause) {
            controller.pause();
          } else {
            controller.resume();
          }

          setState(() {
            _isPause = !_isPause;
          });
        },
      ),
    );
  }
}
188
likes
0
pub points
98%
popularity

Publisher

verified publisherdizoft.ru

Simple CountDown timer. Using for create a simple timer. It's pure all

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on timer_count_down