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.

73 lines
2.1 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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: DefaultTextStyle(
  22. style: const TextStyle(
  23. fontSize: 80,
  24. color: Colors.white,
  25. fontFamily: 'GoogleSans',
  26. ),
  27. child: AnimatedTextKit(
  28. isRepeatingAnimation: false,
  29. pause: const Duration(milliseconds: 0),
  30. onFinished: _onFinish,
  31. animatedTexts: [
  32. RotateAnimatedText(
  33. '3',
  34. transitionHeight: 100 * 2.5,
  35. textStyle: const TextStyle(
  36. color: Colors.white,
  37. ),
  38. duration: Duration(milliseconds: _kInitialSpeed),
  39. ),
  40. RotateAnimatedText(
  41. '2',
  42. transitionHeight: 100 * 2.5,
  43. textStyle: const TextStyle(
  44. color: Colors.white,
  45. ),
  46. duration: Duration(milliseconds: _kInitialSpeed),
  47. ),
  48. RotateAnimatedText(
  49. '1',
  50. transitionHeight: 100 * 2.5,
  51. textStyle: const TextStyle(
  52. color: Colors.white,
  53. ),
  54. duration: Duration(milliseconds: _kInitialSpeed),
  55. ),
  56. RotateAnimatedText(
  57. 'GO!',
  58. textStyle: const TextStyle(
  59. fontSize: 60,
  60. color: Colors.white,
  61. ),
  62. transitionHeight: 120 * 2.5,
  63. duration: Duration(milliseconds: _kInitialSpeed),
  64. ),
  65. ],
  66. ),
  67. ),
  68. );
  69. }
  70. }