my_button.dart 1.7 KB

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