You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.3 KiB

2 years ago
  1. import 'package:animated_text_kit/animated_text_kit.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_riverpod/flutter_riverpod.dart';
  4. class CountdownWidget extends ConsumerWidget {
  5. const CountdownWidget({
  6. required bool isStartPressed,
  7. required Function() onFinish,
  8. required int initialSpeed,
  9. Key? key,
  10. }) : _isStartPressed = isStartPressed,
  11. _onFinish = onFinish,
  12. _kInitialSpeed = initialSpeed,
  13. super(key: key);
  14. final bool _isStartPressed;
  15. final Function() _onFinish;
  16. final int _kInitialSpeed;
  17. @override
  18. Widget build(BuildContext context, WidgetRef ref) {
  19. return Visibility(
  20. visible: _isStartPressed,
  21. child: SizedBox(
  22. width: 250.0,
  23. child: DefaultTextStyle(
  24. style: const TextStyle(
  25. fontSize: 150.0,
  26. color: Colors.white,
  27. fontFamily: 'GoogleSans',
  28. ),
  29. child: AnimatedTextKit(
  30. // totalRepeatCount: 1,
  31. isRepeatingAnimation: false,
  32. pause: const Duration(milliseconds: 0),
  33. onFinished: _onFinish,
  34. animatedTexts: [
  35. RotateAnimatedText(
  36. '3',
  37. transitionHeight: 100 * 2.5,
  38. textStyle: const TextStyle(
  39. color: Colors.white,
  40. ),
  41. duration: Duration(milliseconds: _kInitialSpeed),
  42. ),
  43. RotateAnimatedText(
  44. '2',
  45. transitionHeight: 100 * 2.5,
  46. textStyle: const TextStyle(
  47. color: Colors.white,
  48. ),
  49. duration: Duration(milliseconds: _kInitialSpeed),
  50. ),
  51. RotateAnimatedText(
  52. '1',
  53. transitionHeight: 100 * 2.5,
  54. textStyle: const TextStyle(
  55. color: Colors.white,
  56. ),
  57. duration: Duration(milliseconds: _kInitialSpeed),
  58. ),
  59. RotateAnimatedText(
  60. 'GO!',
  61. textStyle: const TextStyle(
  62. fontSize: 120.0,
  63. color: Colors.white,
  64. ),
  65. transitionHeight: 120 * 2.5,
  66. duration: Duration(milliseconds: _kInitialSpeed),
  67. ),
  68. ],
  69. ),
  70. ),
  71. ),
  72. );
  73. }
  74. }