Giter VIP home page Giter VIP logo

simple_count_down's People

Contributors

ahmedabouelkher avatar dubey2k avatar marcusgalli avatar nizamudeenms avatar piecubed avatar piyush-myswiftly avatar sachin-dahal avatar wiright avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

simple_count_down's Issues

Feature request: set/reinitialise timer

I'm missing a method to change the seconds value when called either as a function call or from setState(){}.

This would enable me to have an increment/decrement button to change the interval of the countdown timer.

Best regards
Ulrich Bjerre

Timer not restarting itself

Hi I start the timer fine but then I want to restart the count down when the timer is done at onFinished with countdownController.restart() but it is not working, here is the widget.

@override
Widget build(BuildContext context) {

return Countdown(
  controller: countdownController,
  seconds: seconds,
  interval: const Duration(milliseconds: 500),
  build: (BuildContext context, double time) {
    countdownController.start();
    print(time);
    return child;
  },
  onFinished: () {
    print('timer done');
    countdownController.restart();
    if (mqttState == MqttAppConnectionState.connected) {
      print('TIMER::: Timer done retrying sending 1..');
    }
  },
  );
}

It prints the countdown at print(time): just fine the first time but the restart does not happen

I am doing something wrong? thanks!

Countdown doesn't restart when I call restart()

InkWell(
onTap: state
? () {
onPressInkFunction(
type,
context,
listLabelByPincodeType['phoneNumber'] ?? '',
);
_countdownController.restart();
context.read().add(
const PincodeEvent.pressedResendOTP(
isTapable: false,
),
);
}
: null,
child: AutoSizeText.rich(
TextSpan(
text: listLabelByPincodeType['footerLabel'] ?? '',
style: Theme.of(context)
.textTheme
.titleMedium
?.copyWith(
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.secondary,
),
),
maxLines: 1,
textAlign: TextAlign.left,
),
);
I have an inkwell with onTap() function but when I tapped the restart function was executed only once. The next time I tap nothing happends.

After Changing seconds doesn't displays change in view

The Problem here is, When we update seconds (duration for which the timer will run) for timer, it doesn't reflect any change to Timer build method, because you assigned _currentMicroSeconds in init method.

To resolve this we can add the below code and this will work in a effecient way -

@override void didUpdateWidget(Countdown oldWidget) { super.didUpdateWidget(oldWidget); if (oldWidget.seconds != widget.seconds) _currentMicroSeconds = widget.seconds * _secondsFactor; }

Also Created a PR, if you find it correct merge it..

Happy Coding..

If the countdown timer is stopped when it has reached zero seconds and event onFinished has not yet been executed.

In this case, the counter is frozen because it does not resume its execution, even when the controler executes the resume method. As a result, the onFinished event is never executed.
Following the logic of the flow of actions. We can say that in this scenario, the user stopped the counter before it was finished. And if it is reactivated through the Resume method, we must only run the event onFinished method, and this must be done only once.

null safety

Any expectations to migrate to nullsafety?

Change format of timer

It will be great if we can have way to choose which format we want for example I want timer to be always shown in 00:00 format example 10:00, 09:00, 00:09.

Feature request: onUpdate

I actually have a second request.

It would be nice to have an onProgress or onUpdate callback too. This would enable me to refresh/update other UI elements at every update rate (e.g. once every 100ms)

Best regards
Ulrich Bjerre

Create multiple timers at the same time, display exception

Create multiple timers at the same time, display exception
The previous timer will reset the time, and the next one will inherit the remaining time of the previous one

  Widget _timerCountDown() {
    return Countdown(
      // controller: timerController,
      seconds: 120,
      build: (BuildContext context, double time) {
        if (time < 5.0) {
          return Text("ღ( ´・ᴗ・` )",style: TextStyle(color: Colors.white),);
        }else{
          return Text(time.toString(),style: TextStyle(color: Colors.white),);
        }
      },
      interval: Duration(milliseconds: 100),
      onFinished: () {
        print('Timer is done!');
      },
    );
  }

Infinte looping while debug

    if (_currentMicroSeconds != 0) {
      _timer = Timer.periodic(
        widget.interval,
        (Timer timer) {
          if (_currentMicroSeconds == 0) {
            timer.cancel();

The == on the second last line (Line 127) needs to be changed to <= , otherwise I see the _currentMicroSeconds going negative making the countdown endless.

Screen.Recording.2021-04-17.at.1.58.14.AM.mov

Access to current time outside from widget?

hi DizoftTeam,

Congratulations first! Simple widget, self explaining and works great!

Is it possible to access current times outside of widget?

The example only shows how to access the time inside the widget:

build: (BuildContext context, double time) => Text(time.toString()),

I would have expected this to be via _controller, unfortunately I don't see a property time!?

Thanks
pc-Justin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.