Add neutral option to choice animation (#3612)

This commit is contained in:
Kelrap 2025-08-01 13:15:51 -04:00 committed by GitHub
parent f491cdaece
commit f19d717e87
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
const int choiceArrayAnimationDuration = 500;
/// Show different animation depending on whether
/// the choice is correct, wrong, or neither
class ChoiceAnimationWidget extends StatefulWidget {
final bool isSelected;
final bool? isCorrect;
@ -12,7 +14,7 @@ class ChoiceAnimationWidget extends StatefulWidget {
const ChoiceAnimationWidget({
super.key,
required this.isSelected,
required this.isCorrect,
this.isCorrect,
required this.child,
});
@ -77,26 +79,28 @@ class ChoiceAnimationWidgetState extends State<ChoiceAnimationWidget>
@override
Widget build(BuildContext context) {
return widget.isCorrect == true
? AnimatedBuilder(
animation: _animation,
builder: (context, child) {
return Transform.scale(
scale: _animation.value,
child: child,
return widget.isCorrect == null
? widget.child
: widget.isCorrect == true
? AnimatedBuilder(
animation: _animation,
builder: (context, child) {
return Transform.scale(
scale: _animation.value,
child: child,
);
},
child: widget.child,
)
: AnimatedBuilder(
animation: _animation,
builder: (context, child) {
return Transform.rotate(
angle: _animation.value,
child: child,
);
},
child: widget.child,
);
},
child: widget.child,
)
: AnimatedBuilder(
animation: _animation,
builder: (context, child) {
return Transform.rotate(
angle: _animation.value,
child: child,
);
},
child: widget.child,
);
}
}