Make Your Own Outlined Button With Gradient In Flutter

[Solved] Make Your Own Outlined Button With Gradient In Flutter | Dart - Code Explorer | yomemimo.com
Question : add gradient to flutter button

Answered by : harsh-tenguriya-chv2uja6gju0

DecoratedBox( decoration: BoxDecoration(gradient: LinearGradient(colors: [Colors.pink, Colors.green])), child: ElevatedButton( onPressed: () {}, style: ElevatedButton.styleFrom(primary: Colors.transparent), child: Text('Elevated Button'), ),
)

Source : https://stackoverflow.com/questions/52243364/how-to-add-a-gradient-to-a-button-in-flutter/67570467#67570467 | Last Update : Tue, 17 Aug 21

Question : Make your own outlined button with gradient in flutter

Answered by : harsh-tenguriya-chv2uja6gju0

class MyOutlinedButton extends StatelessWidget { final VoidCallback onPressed; final Widget child; final ButtonStyle? style; final Gradient? gradient; final double thickness; const MyOutlinedButton({ Key? key, required this.onPressed, required this.child, this.style, this.gradient, this.thickness = 2, }) : super(key: key); @override Widget build(BuildContext context) { return DecoratedBox( decoration: BoxDecoration(gradient: gradient), child: Container( color: Colors.white, margin: EdgeInsets.all(thickness), child: OutlinedButton( onPressed: onPressed, style: style, child: child, ), ), ); }
}
//Usage:
MyOutlinedButton( onPressed: () {}, gradient: LinearGradient(colors: [Colors.indigo, Colors.pink]), child: Text('OutlinedButton'),
)

Source : https://stackoverflow.com/questions/52243364/how-to-add-a-gradient-to-a-button-in-flutter/67570467#67570467 | Last Update : Tue, 17 Aug 21

Answers related to make your own outlined button with gradient in flutter

Code Explorer Popular Question For Dart