iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
😽
Flutter: Gradient Ripple Button
You should use MaterialButton and Container.
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Kindacode.com'),
),
body: Center(
child: Container(
width: 300,
height: 100,
decoration: const ShapeDecoration(
shape: StadiumBorder(),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Colors.blue, Colors.orange, Colors.green],
),
),
child: MaterialButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const StadiumBorder(),
child: const Text(
'A Samll Button',
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () {
debugPrint('Hello!');
},
),
)),
);
}
Discussion