I have this class, trying to insert icon and maybe rotating it inside the container depending on rotationAngle.
class ReusableCardIconLayout extends StatelessWidget {
final double? rotationAngle;
ReusableCardIconLayout({this.rotationAngle});
@override
Widget build(BuildContext context) {
return Expanded(
flex: 2,
child: Transform.rotate(
angle: rotationAngle == null ? 0.0 : rotationAngle,
),
);
}
}
Where, rotationAngle is optional, and so I made it nullable.
Now, the line
angle: rotationAngle == null? 0.0 : rotationAngle,
is showing the error "The argument type 'double?' can't be assigned to the parameter type 'double'".
Why it is giving such error? I have already checked if it is null or not. And if it was, then giving default 0.0 value or else using it's value. What's wrong in this line?
Isn't there any way to use ternary operator like above and solve it?
Is giving the default parameter value only the option left?