IconButton(//... visualDensity: VisualDensity.minimumDensity,), // The argument type 'double' can't be assigned to the parameter type 'VisualDensity?'. Why can't I assign?
CodePudding user response:
The type of visualDensity is nullable. Try using VisualDensity.minimumDensity!
I also suggest adding a null check. VisualDensity.minimumDensity == null ? 0.0 : VisualDensity.minimumDensity!
CodePudding user response:
So the next time you run into an error like this, what it is basically telling you is that you're trying to pass the wrong data to the parameter.
For your case this is what you should do
IconButton(onPressed: (){}, icon: Icon(Icons.enhance_photo_translate), visualDensity: VisualDensity(horizontal: 4.0, vertical: 4.0),)
Pass a visual density object and not a double primitive type.