import 'package:fast/extension/layout.dart'; import 'package:flutter/material.dart'; class RRectButton extends StatelessWidget { const RRectButton( this.text, { Key? key, this.width = 64, this.height = 32, this.radius = 12, this.textColor, this.fontSize, this.backgroundColor = Colors.transparent, this.gradientColors = const [Colors.transparent, Colors.transparent], this.onPressed, }) : super(key: key); final String text; final double width; final double height; final Color? textColor; final double? fontSize; final Color? backgroundColor; final List? gradientColors; final double radius; final VoidCallback? onPressed; @override Widget build(BuildContext context) { return SizedBox( width: width, height: height, child: Container( padding: EdgeInsets.zero, margin: EdgeInsets.zero, decoration: BoxDecoration( gradient: gradientColors ?.let((it) => LinearGradient(colors: gradientColors!)), borderRadius: BorderRadius.circular(radius), ), child: ElevatedButton( onPressed: onPressed, child: Text( text, style: textColor ?.let((it) => TextStyle(color: textColor, fontSize: fontSize)), ), style: ButtonStyle( padding: MaterialStateProperty.all(EdgeInsets.zero), // tapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: MaterialStateProperty.all(RoundedRectangleBorder( borderRadius: BorderRadius.circular(radius))), backgroundColor: MaterialStateProperty.all(backgroundColor), ), ), ), ); } } class RRectOutlinedButton extends StatelessWidget { const RRectOutlinedButton( this.text, { Key? key, this.width = 64, this.height = 32, this.radius = 12, this.textColor, this.fontSize, this.backgroundColor = Colors.transparent, this.gradientColors, this.onPressed, }) : super(key: key); final String text; final double width; final double height; final Color? textColor; final double? fontSize; final Color? backgroundColor; final List? gradientColors; final double radius; final VoidCallback? onPressed; @override Widget build(BuildContext context) { return SizedBox( width: width, height: height, child: Container( padding: EdgeInsets.zero, margin: EdgeInsets.zero, decoration: BoxDecoration( gradient: gradientColors ?.let((it) => LinearGradient(colors: gradientColors!)), borderRadius: BorderRadius.circular(radius), ), child: OutlinedButton( onPressed: onPressed, child: Text( text, style: TextStyle(color: textColor, fontSize: fontSize), ), style: OutlinedButton.styleFrom( padding: EdgeInsets.zero, // tapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(radius), ), side: const BorderSide(color: Colors.blue, style: BorderStyle.solid), backgroundColor: backgroundColor, ), ), ), ); } }