code_button.dart 924 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import 'package:flutter/material.dart';
  2. import 'package:shuqi/model/sq_color.dart';
  3. class CodeButton extends StatelessWidget {
  4. final VoidCallback onPressed;
  5. final int coldDownSeconds;
  6. CodeButton({required this.onPressed, required this.coldDownSeconds});
  7. @override
  8. Widget build(BuildContext context) {
  9. if (coldDownSeconds > 0) {
  10. return Container(
  11. width: 95,
  12. child: Center(
  13. child: Text(
  14. '${coldDownSeconds}s',
  15. style: TextStyle(fontSize: 14, color: SQColor.primary),
  16. ),
  17. ),
  18. );
  19. }
  20. return GestureDetector(
  21. onTap: onPressed,
  22. child: Container(
  23. width: 95,
  24. child: Text('获取验证码',
  25. textAlign: TextAlign.center,
  26. style: TextStyle(
  27. fontSize: 14,
  28. fontWeight: FontWeight.normal,
  29. color: SQColor.primary)),
  30. ),
  31. );
  32. }
  33. }