I am using linear gradient property in background. Every time I change a card (radio), the _selectedColor
should change as a radio is a map with a property color radios![index].color
. Well, it does happen but very slowly. I takes about a minute to gradually change the _selectedColor
. How can I speed up this process ?
VxAnimatedBox()
.size(context.screenWidth, context.screenHeight)
.withGradient(
LinearGradient(
colors: [
Colors.blue,
_selectedColor,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
)
On card change, _selectedColor
gets updated:
onPageChanged: (index) {
final colorHex = radios![index].color;
print(colorHex);
setState(() {
_selectedColor = Color(int.parse(colorHex));
});
},
I have tried to use transform but it didn't solve the issue.
CodePudding user response:
Have you tried adding a duration to your animated box like so:
VxAnimatedBox()
.size(context.screenWidth, context.screenHeight)
.seconds(sec: 2)
.withGradient(
LinearGradient(
colors: [
Colors.blue,
_selectedColor,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
)
Notice the added call to the seconds
methods