rounded_button.dart 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import 'package:flowy_infra/size.dart';
  2. import 'package:flutter/material.dart';
  3. class RoundedTextButton extends StatelessWidget {
  4. final VoidCallback? onPressed;
  5. final String? title;
  6. final double? width;
  7. final double? height;
  8. final BorderRadius borderRadius;
  9. final Color borderColor;
  10. final Color color;
  11. final Color textColor;
  12. final double fontSize;
  13. const RoundedTextButton({
  14. Key? key,
  15. this.onPressed,
  16. this.title,
  17. this.width,
  18. this.height,
  19. this.borderRadius = Corners.s12Border,
  20. this.borderColor = Colors.transparent,
  21. this.color = Colors.transparent,
  22. this.textColor = Colors.white,
  23. this.fontSize = 16,
  24. }) : super(key: key);
  25. @override
  26. Widget build(BuildContext context) {
  27. return ConstrainedBox(
  28. constraints: BoxConstraints(
  29. minWidth: 10,
  30. maxWidth: width ?? double.infinity,
  31. minHeight: 10,
  32. maxHeight: height ?? 60,
  33. ),
  34. child: Container(
  35. decoration: BoxDecoration(
  36. border: Border.all(color: borderColor),
  37. borderRadius: borderRadius,
  38. color: color,
  39. ),
  40. child: SizedBox.expand(
  41. child: TextButton(
  42. child: Text(
  43. title ?? '',
  44. style: TextStyle(color: textColor, fontSize: fontSize),
  45. ),
  46. onPressed: onPressed,
  47. ),
  48. ),
  49. ),
  50. );
  51. }
  52. }
  53. class RoundedImageButton extends StatelessWidget {
  54. final VoidCallback? press;
  55. final double size;
  56. final BorderRadius borderRadius;
  57. final Color borderColor;
  58. final Color color;
  59. final Widget child;
  60. const RoundedImageButton({
  61. Key? key,
  62. this.press,
  63. required this.size,
  64. this.borderRadius = BorderRadius.zero,
  65. this.borderColor = Colors.transparent,
  66. this.color = Colors.transparent,
  67. required this.child,
  68. }) : super(key: key);
  69. @override
  70. Widget build(BuildContext context) {
  71. return SizedBox(
  72. width: size,
  73. height: size,
  74. child: TextButton(
  75. onPressed: press,
  76. style: ButtonStyle(
  77. shape: MaterialStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(
  78. borderRadius: borderRadius,
  79. ))),
  80. child: child,
  81. ),
  82. );
  83. }
  84. }