mybutton.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import 'package:flutter/material.dart';
  2. class MyElevatedButton extends StatelessWidget {
  3. final BorderRadiusGeometry? borderRadius;
  4. final double? width;
  5. final double height;
  6. final Gradient gradient;
  7. final VoidCallback? onPressed;
  8. final Widget child;
  9. const MyElevatedButton({
  10. super.key,
  11. required this.onPressed,
  12. required this.child,
  13. this.borderRadius,
  14. this.width,
  15. this.height = 44.0,
  16. this.gradient = const LinearGradient(colors: [Colors.cyan, Colors.indigo]),
  17. });
  18. @override
  19. Widget build(BuildContext context) {
  20. final borderRadius = this.borderRadius ?? BorderRadius.circular(0);
  21. return Container(
  22. width: width,
  23. height: height,
  24. decoration: BoxDecoration(
  25. gradient: gradient,
  26. borderRadius: borderRadius,
  27. boxShadow: const [
  28. BoxShadow(
  29. color: Colors.black,
  30. //spreadRadius: 10,
  31. //blurRadius: 2,
  32. ),
  33. ],
  34. ),
  35. child: ElevatedButton(
  36. onPressed: onPressed,
  37. style: ElevatedButton.styleFrom(
  38. backgroundColor: Colors.transparent,
  39. shadowColor: Colors.transparent,
  40. shape: RoundedRectangleBorder(borderRadius: borderRadius),
  41. ),
  42. child: child,
  43. ),
  44. );
  45. }
  46. }