xxxxxxxxxx
DecoratedBox(
decoration: BoxDecoration(gradient: LinearGradient(colors: [Colors.pink, Colors.green])),
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(primary: Colors.transparent),
child: Text('Elevated Button'),
),
)
xxxxxxxxxx
RaisedGradientButton(
child: Text(
'Button',
style: TextStyle(color: Colors.white),
),
gradient: LinearGradient(
colors: <Color>[Colors.green, Colors.black],
),
onPressed: (){
print('button clicked');
}
),
xxxxxxxxxx
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'),
)
xxxxxxxxxx
import 'package:flutter/material.dart';
import 'package:flutter_gradients/flutter_gradients.dart';
class GradientButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
// Add button functionality here
},
style: ElevatedButton.styleFrom(
primary: Colors.transparent,
elevation: 0,
padding: EdgeInsets.all(16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(color: Colors.white),
),
shadowColor: Colors.transparent,
textStyle: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 24),
visualDensity: VisualDensity.compact,
minimumSize: Size(150, 48),
fixedSize: Size(150, 48),
// Use the gradient from the flutter_gradients package
// You can also create your own gradients using Flutter's LinearGradient
backgroundGradient: FlutterGradients.jShine(
tileMode: TileMode.clamp,
),
),
child: Text('Gradient Button'),
);
}
}
xxxxxxxxxx
import 'package:flutter/material.dart';
class RoundedButtonWidget extends StatelessWidget {
final String buttonText;
final double width;
final Function onpressed;
RoundedButtonWidget({
required this.buttonText,
required this.width,
required this.onpressed,
});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black26, offset: Offset(0, 4), blurRadius: 5.0)
],
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
stops: [0.0, 1.0],
colors: [
Colors.deepPurple.shade400,
Colors.deepPurple.shade200,
],
),
color: Colors.deepPurple.shade300,
borderRadius: BorderRadius.circular(20),
),
child: ElevatedButton(
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
),
minimumSize: MaterialStateProperty.all(Size(width, 50)),
backgroundColor:
MaterialStateProperty.all(Colors.transparent),
// elevation: MaterialStateProperty.all(3),
shadowColor:
MaterialStateProperty.all(Colors.transparent),
),
onPressed: () {
onpressed();
},
child: Padding(
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
),
child: Text(
buttonText,
style: TextStyle(
fontSize: 18,
// fontWeight: FontWeight.w700,
color: Colors.white,
),
),
),
),
),
);
}
}