countdown.dart 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3. /// Description: count down for splash
  4. /// Time : 02/21/2024 Wednesday
  5. /// Author : liuyuqi.gov@msn.cn
  6. class Countdown extends StatefulWidget {
  7. const Countdown({Key? key}) : super(key: key);
  8. @override
  9. State<Countdown> createState() => _CountdownState();
  10. }
  11. class _CountdownState extends State<Countdown> {
  12. late Animation<double> _animation;
  13. late AnimationController _controller;
  14. @override
  15. Widget build(BuildContext context) {
  16. return GestureDetector(
  17. child: Container(
  18. color: const Color(0xFF1E90FF),
  19. child: Center(
  20. child: AnimatedBuilder(
  21. animation: _animation,
  22. builder: (context, child) {
  23. return Text(
  24. '${_animation.value.toInt()}',
  25. style: const TextStyle(
  26. fontSize: 60,
  27. color: Colors.white,
  28. ),
  29. );
  30. },
  31. ),
  32. ),
  33. ));
  34. }
  35. @override
  36. void initState() {
  37. super.initState();
  38. SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
  39. statusBarBrightness: Brightness.light,
  40. statusBarIconBrightness: Brightness.light,
  41. ));
  42. }
  43. @override
  44. void dispose() {
  45. super.dispose();
  46. _controller.dispose();
  47. }
  48. }