flutter_countdown_timer 1.5.0 copy "flutter_countdown_timer: ^1.5.0" to clipboard
flutter_countdown_timer: ^1.5.0 copied to clipboard

outdated

A flutter countdown timer. [10 days 5:30:46] ⬇⬇⬇⬇

CountdownTimer #

A simple flutter countdown timer component.

Installing #

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_countdown_timer: ^1.4.0

Install it

$ flutter pub get

#

name description
endTime Countdown end time stamp
onEnd Countdown end event
emptyWidget The widget displayed at the end of the countdown
daysSymbol final Widget daysSymbol
hoursSymbol final Widget hoursSymbol
minSymbol final Widget minSymbol
secSymbol final Widget secSymbol
textStyle final TextStyle textStyle
widgetBuilder Widget Function(BuildContext context, CurrentRemainingTime time)

Example #

Now in your Dart code, you can use:

@override
  Widget build(BuildContext context) {
    int endTime = DateTime.now().millisecondsSinceEpoch + 1000 * 60 * 60;
    return Scaffold(
      body: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: <Widget>[
          CountdownTimer(
            endTime: endTime,
          ),
          CountdownTimer(
            endTime: endTime,
            textStyle: TextStyle(fontSize: 30, color: Colors.pink),
          ),
          CountdownTimer(
            endTime: endTime,
            widgetBuilder: (_, CurrentRemainingTime time) {
              return Text(
                  'days: [ ${time.days} ], hours: [ ${time.hours} ], min: [ ${time.min} ], sec: [ ${time.sec} ]');
            },
          ),
          CountdownTimer(
            endTime: endTime,
            widgetBuilder: (BuildContext context, CurrentRemainingTime time) {
              List<Widget> list = [];
              if(time.days != null) {
                list.add(Row(
                  children: <Widget>[
                    Icon(Icons.sentiment_dissatisfied),
                    Text(time.days.toString()),
                  ],
                ));
              }
              if(time.hours != null) {
                list.add(Row(
                  children: <Widget>[
                    Icon(Icons.sentiment_satisfied),
                    Text(time.hours.toString()),
                  ],
                ));
              }
              if(time.min != null) {
                list.add(Row(
                  children: <Widget>[
                    Icon(Icons.sentiment_very_dissatisfied),
                    Text(time.min.toString()),
                  ],
                ));
              }
              if(time.sec != null) {
                list.add(Row(
                  children: <Widget>[
                    Icon(Icons.sentiment_very_satisfied),
                    Text(time.sec.toString()),
                  ],
                ));
              }

              return Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: list,
              );
            },
          ),
        ],
      ),
    );
  }

Countdown #

CountdownController countdownController = CountdownController(duration: Duration(minutes: 1));


Scaffold(
      body: Center(
        child: Countdown(countdownController: countdownController),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(countdownController.isRunning ? Icons.stop : Icons.play_arrow),
        onPressed: () {
          if(!countdownController.isRunning) {
          ///start
            countdownController.start();
          } else {
          ///pause
            countdownController.stop();
          }
          setState(() {
            ///change icon
          });
        },
      ),
    )

000.gif

./example_2.png /example_0.png

example_1.png 000.gif

307
likes
0
pub points
99%
popularity

Publisher

unverified uploader

A flutter countdown timer. [10 days 5:30:46] ⬇⬇⬇⬇

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_countdown_timer