I am working on some code I did not create myself and am running into an error that I can’t quite figure out.
In the app, there is a component called Spinner. Below are the requirements for Spinner.
final Widget child;
final bool loading;
final double opacity;
final Color color;
final Animation<Color> value;
Spinner({Key key, u/required this.child, u/required this.loading, this.opacity = 0.3, this.color = Colors.grey, this.value}) : super(key: key);
However, when I implemented this version of Spinner, my Android Studio flagged the last variable (i.e., value) as a problem. It wanted this to be required, though it wasn’t before. So, I made it required, and it tells me that the default value cannot be Null. However, I can’t seem to enter a default value. I also can’t find any documentation that makes it clear how to enter a default value for this type of variable.
2
Answers
In this case, the problem is not to find any animation to make the compiler happy, it is to find the animation that make sense to the UI design.
For example, I can fit the default value like this:
This transforms a white color to black in 2.5 seconds. Is this what you want the default behaviour to look like? Maybe, maybe not. It depends on the design.
If you are not sure about the design, why not making it nullable for now?
If you like to have single value for animation you can pass
And for more customization, create a ColorTween like with animation controller