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

PlatformAndroidiOS
outdated

this project was copy from countdown_flutter

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>[
            Center(
              child: CountdownFlutterCopy(
                builder: (ctx, duration) {
                  return Text(
                    "${duration.inSeconds}",
                    style: const TextStyle(fontSize: 30),
                  );
                },
                interval: const Duration(seconds: 1),
                duration: const Duration(hours: 2),
                countdownStatus: status,
              ),
            ),
            ElevatedButton(
                onPressed: () {
                  setState(() {
                    if (status == CountdownStatus.play) {
                      status = CountdownStatus.pause;
                    } else {
                      status = CountdownStatus.play;
                    }
                    buttonText = buttonText == "play" ? "pause" : "play";
                  });
                },
                child: Text(buttonText))
          ],
        ),
      ),
    );
  }
}
1
likes
130
pub points
6%
popularity

Publisher

unverified uploader

this project was copy from countdown_flutter

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on countdown_flutter_copy