cupertino_timer 1.0.2 copy "cupertino_timer: ^1.0.2" to clipboard
cupertino_timer: ^1.0.2 copied to clipboard

An iOS style countdown timer. Inspired by the native timer app on iOS.

example/lib/main.dart

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

void main() {
  runApp(TimerApp());
}

class TimerApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'cupertino_timer',
      home: TimerHomePage(title: 'cupertino_timer'),
    );
  }
}

class TimerHomePage extends StatefulWidget {
  TimerHomePage({Key key, this.title}) : super(key: key);
  final String title;

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

class _TimerHomePageState extends State<TimerHomePage> {
  AnimationController controller;

  @override
  Widget build(BuildContext context) {
    controller = AnimationController(vsync: this);
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              margin: EdgeInsets.all(20),
              width: 200,
              height: 200,
              child: CupertinoTimer(
                duration: Duration(minutes: 1),
              ),
            ),
            Container(
              margin: EdgeInsets.all(20),
              width: 200,
              height: 200,
              child: CupertinoTimer(
                duration: Duration(minutes: 1),
                startOnInit: true,
                timeStyle: TextStyle(
                    fontFamily: 'Avenir Next', fontWeight: FontWeight.bold),
                ringColor: Colors.blue,
                ringStroke: 10,
                controller: this.controller,
              ),
            ),
            TextButton(
                onPressed: () {
                  this.controller.forward();
                },
                child: Text("Start")),
            TextButton(
                onPressed: () {
                  this.controller.stop();
                },
                child: Text("Pause")),
            TextButton(
                onPressed: () {
                  this.controller.reset();
                },
                child: Text("Reset")),
          ],
        ),
      ),
    );
  }
}
8
likes
150
pub points
65%
popularity

Publisher

verified publisherverygoodtech.co

An iOS style countdown timer. Inspired by the native timer app on iOS.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on cupertino_timer