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.

76 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. isRepeatingAnimation: false,
  31. pause: const Duration(milliseconds: 0),
  32. onFinished: _onFinish,
  33. animatedTexts: [
  34. RotateAnimatedText(
  35. '3',
  36. transitionHeight: 100 * 2.5,
  37. textStyle: const TextStyle(
  38. color: Colors.white,
  39. ),
  40. duration: Duration(milliseconds: _kInitialSpeed),
  41. ),
  42. RotateAnimatedText(
  43. '2',
  44. transitionHeight: 100 * 2.5,
  45. textStyle: const TextStyle(
  46. color: Colors.white,
  47. ),
  48. duration: Duration(milliseconds: _kInitialSpeed),
  49. ),
  50. RotateAnimatedText(
  51. '1',
  52. transitionHeight: 100 * 2.5,
  53. textStyle: const TextStyle(
  54. color: Colors.white,
  55. ),
  56. duration: Duration(milliseconds: _kInitialSpeed),
  57. ),
  58. RotateAnimatedText(
  59. 'GO!',
  60. textStyle: const TextStyle(
  61. fontSize: 120.0,
  62. color: Colors.white,
  63. ),
  64. transitionHeight: 120 * 2.5,
  65. duration: Duration(milliseconds: _kInitialSpeed),
  66. ),
  67. ],
  68. ),
  69. ),
  70. ),
  71. );
  72. }
  73. }