LinearButton.dart 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. final FontWeight textWeight;
  13. LinearButton(
  14. {this.btntext = '',
  15. this.onTapHomeMenu,
  16. this.colorList = const [Color(0xFFC2524D), Color(0xFFC2524D)],
  17. this.btnHeight = 48.0,
  18. this.childWidget,
  19. this.textColor = Colors.white,
  20. this.textSize = 16.0,
  21. this.radius = 4.0,
  22. this.textWeight=FontWeight.w600});
  23. @override
  24. Widget build(BuildContext context) {
  25. return Container(
  26. height: btnHeight,
  27. decoration: BoxDecoration(
  28. gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: colorList),
  29. borderRadius: BorderRadius.all(Radius.circular(radius))),
  30. child: Material(
  31. color: Colors.transparent,
  32. child: InkWell(
  33. onTap: onTapHomeMenu,
  34. child: childWidget != null
  35. ? childWidget
  36. : Center(
  37. child: Text(
  38. btntext,
  39. style: TextStyle(fontSize: textSize, fontWeight: textWeight, color: textColor),
  40. )),
  41. ),
  42. ),
  43. );
  44. }
  45. }