fast_btn.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import 'package:fast/constants.dart';
  2. import 'package:fast/utils/size_fit.dart';
  3. import 'package:flutter/material.dart';
  4. // ignore: must_be_immutable
  5. class FastBtn extends StatelessWidget {
  6. String title;
  7. bool disable;
  8. double width, height;
  9. Widget? imgWidget;
  10. // Color disableColor = const Color(0xFF363F4D);
  11. // ignore: prefer_typing_uninitialized_variables
  12. var callback;
  13. FastBtn(
  14. {Key? key,
  15. required this.title,
  16. required this.disable,
  17. required this.width,
  18. required this.height,
  19. required this.callback,
  20. Widget? img})
  21. : super(key: key){
  22. if (img!=null){
  23. imgWidget = img;
  24. }
  25. }
  26. @override
  27. Widget build(BuildContext context) {
  28. return GestureDetector(
  29. onTap: () {
  30. callback();
  31. },
  32. child: Opacity(opacity: disable?0.4:1.0,child: Container(
  33. width: width,
  34. height: height,
  35. alignment: Alignment.center,
  36. decoration: BoxDecoration(
  37. color: kThemeColor,
  38. borderRadius: BorderRadius.all(Radius.circular(height / 2.0))),
  39. child: imgWidget ?? Text(
  40. title,
  41. style: TextStyle(
  42. color: kBgColor,
  43. fontSize: 16.px,
  44. decoration: TextDecoration.none,
  45. fontWeight: FontWeight.w900),
  46. ),
  47. ),),
  48. );
  49. }
  50. }