rive-flutter
rive-flutter copied to clipboard
how to change color of shape object
Hey, I am trying to change the color of a component called "body" in a rive asset but it's not reflecting.
// code to change color:
ElevatedButton(
onPressed: () {
_riveArtboard!.forEachComponent((child) {
if (child.name == 'body') {
debugPrint("Body found");
if (child is Shape) {
debugPrint("it's a shape");
final Shape shape = child;
setState(() {
shape.fills.first.paint.color = Colors.yellow;
});
}
}
});
},
child: const Text('Change Color')),
// rive widget:
Container(
width: 400,
height: 400,
color: Colors.green,
child:
const RiveAnimation.asset(
'assets/casual_character.riv',
animations: ['hi'],
fit: BoxFit.contain,
antialiasing: true,
),
),
I do get print outputs: "body found", "it's a shape" but the color didn't change