| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- 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<Color>? 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<Color>? 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,
- ),
- ),
- ),
- );
- }
- }
|