Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- class GradientButton extends StatelessWidget {
- final String label;
- final double fontSize;
- final Color backgroundColor;
- final LinearGradient gradient;
- final Color textColor;
- final Color borderColor;
- final double width;
- final double height;
- final IconData icon;
- final Function onTap;
- final double borderRadius;
- const GradientButton({
- Key key,
- this.label = "GraientButton",
- this.fontSize,
- this.backgroundColor,
- this.gradient,
- this.textColor = Colors.white,
- this.borderColor,
- this.width,
- this.height = 50,
- this.icon,
- @required this.onTap,
- this.borderRadius = 40,
- }) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return ClipRRect(
- borderRadius: BorderRadius.circular(borderRadius),
- child: Material(
- color: backgroundColor ?? Theme.of(context).accentColor,
- child: InkWell(
- onTap: onTap,
- child: Ink(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
- gradient: gradient,
- border:
- borderColor == null ? null : Border.all(color: borderColor),
- ),
- child: Container(
- width: width,
- height: height,
- alignment: Alignment.center,
- child: label == ''
- ? icon == null ? Container() : Icon(icon, color: textColor)
- : Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- icon == null
- ? Container()
- : Icon(icon, color: textColor),
- Container(width: icon == null ? 0 : 7),
- Text(
- label,
- style: TextStyle(
- color: textColor,
- fontWeight: FontWeight.bold,
- fontSize: fontSize,
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment