my_button.dart 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/res/resources.dart';
  3. import 'package:liftmanager/utils/theme_utils.dart';
  4. class MyButton extends StatelessWidget {
  5. const MyButton({
  6. Key key,
  7. this.text: "",
  8. this.textColor,
  9. this.borderColor,
  10. this.borderWidth = 0,
  11. @required this.onPressed,
  12. this.colors,
  13. this.height = 44,
  14. this.fontSize = Dimens.font_sp18,
  15. }) : super(key: key);
  16. final String text;
  17. final VoidCallback onPressed;
  18. final List<Color> colors;
  19. final Color textColor;
  20. final Color borderColor;
  21. final double borderWidth;
  22. final double height;
  23. final double fontSize;
  24. @override
  25. Widget build(BuildContext context) {
  26. // bool isDark = ThemeUtils.isDark(context);
  27. return FlatButton(
  28. onPressed: onPressed,
  29. child: Column(
  30. children: <Widget>[
  31. Container(
  32. height: this.height,
  33. // width: double.infinity,
  34. padding: EdgeInsets.only(left: 10, right: 10),
  35. alignment: Alignment.center,
  36. decoration: BoxDecoration(
  37. color: Colors.white,
  38. borderRadius: BorderRadius.circular(this.height / 2),
  39. gradient: LinearGradient(
  40. colors:
  41. this.colors ?? [Color(0xFF00D4FF), Color(0xFF007CFF)]),
  42. border: Border.all(
  43. color: this.borderColor ?? Colors.transparent,
  44. width: this.borderWidth)),
  45. child: Text(text,
  46. style: TextStyle(
  47. fontSize: this.fontSize,
  48. color: this.textColor ?? Colors.white,
  49. )),
  50. ),
  51. ],
  52. ),
  53. );
  54. }
  55. }