To apply a gradient to the barrier color of a flutter showDialog or AlertDialog, you can define a BoxDecoration with a LinearGradient as the background of the AlertDialog. Here's an example:
final gradient = LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: [
Colors.blue,
Colors.red,
],
);
showDialog(
context: context,
builder: (context) => Container(
decoration: BoxDecoration(
gradient: gradient,
),
child: AlertDialog(
title: Text('Title'),
content: Text('Content'),
),
),
);
This will apply the gradient as the background of the AlertDialog and show it with the gradiented barrier color.
Asked: 2022-02-22 11:00:00 +0000
Seen: 9 times
Last updated: Aug 09 '21