countdown_flutter_copy 0.0.5 copy "countdown_flutter_copy: ^0.0.5" to clipboard
countdown_flutter_copy: ^0.0.5 copied to clipboard

this library is clonning 100% from https://github.com/Leocardoso94/flutter-countdown if you want to learn how to use it, you can go to the real one here https://pub.dev/packages/countdown_flutter *Add [...]

example/lib/main.dart

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

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

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

class _MyAppState extends State<MyApp> {
  final _done = false;

  @override
  void initState() {
    super.initState();
  }

  String buttonText = "pause";
  CountdownStatus status = CountdownStatus.play;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: Text(_done ? 'Finished!' : 'Counting...'),
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: <Widget>[
            Row(
              children: [
                const Expanded(child: SizedBox()),
                SizedBox(
                  width: 120,
                  child: CountdownFormatted(
                    onTick: (duration) {
                      debugPrint("tick");
                    },
                    builder: (ctx, String duration) {
                      return Text(
                        duration,
                        style: const TextStyle(fontSize: 30),
                      );
                    },
                    interval: const Duration(seconds: 1),
                    duration: Duration(minutes: (45/60).ceil()),
                    countdownStatus: status,
                  ),
                ),
                const Expanded(child: SizedBox()),
              ],
            ),
            ElevatedButton(
                onPressed: () {
                  setState(() {
                    if (status == CountdownStatus.play) {
                      status = CountdownStatus.pause;
                    } else {
                      status = CountdownStatus.play;
                    }
                    buttonText = buttonText == "play" ? "pause" : "play";
                  });
                },
                child: Text(buttonText))
          ],
        ),
      ),
    );
  }
}
1
likes
120
pub points
20%
popularity

Publisher

unverified uploader

this library is clonning 100% from https://github.com/Leocardoso94/flutter-countdown if you want to learn how to use it, you can go to the real one here https://pub.dev/packages/countdown_flutter *Adding by my self - I have been working to add pause function to this library. of you want to try it, you can check in sample - I put onTick function to track every singgle ticking on time frame

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on countdown_flutter_copy