LinearButton.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:flutter/material.dart';
  2. typedef void OnTapHomeMenu();
  3. class LinearButton extends StatelessWidget {
  4. final String btntext;
  5. final OnTapHomeMenu onTapHomeMenu;
  6. final List<Color> colorList;
  7. final num btnHeight;
  8. final Widget childWidget;
  9. final Color textColor;
  10. final num textSize;
  11. final num radius;
  12. LinearButton(
  13. {this.btntext = '',
  14. this.onTapHomeMenu,
  15. this.colorList = const [Color(0xFFC2524D), Color(0xFFC2524D)],
  16. this.btnHeight = 48.0,
  17. this.childWidget,
  18. this.textColor = Colors.white,
  19. this.textSize = 16.0,
  20. this.radius = 4.0});
  21. @override
  22. Widget build(BuildContext context) {
  23. return Container(
  24. height: btnHeight,
  25. decoration: BoxDecoration(
  26. gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: colorList),
  27. borderRadius: BorderRadius.all(Radius.circular(radius))),
  28. child: Material(
  29. color: Colors.transparent,
  30. child: InkWell(
  31. onTap: onTapHomeMenu,
  32. child: childWidget != null
  33. ? childWidget
  34. : Center(
  35. child: Text(
  36. btntext,
  37. style: TextStyle(fontSize: textSize, fontWeight: FontWeight.w600, color: textColor),
  38. )),
  39. ),
  40. ),
  41. );
  42. }
  43. }