When specifying widget size in flutter should I use int or double? For example, should it be SizedBox(width:8)
, or SizedBox(width:8.0)
?
I tried looking into flutter docs, but could find anything about this, so instead I looked for examples: https://docs.flutter.dev/development/ui/layout and https://api.flutter.dev/flutter/widgets/SizedBox-class.html, but they seem to be inconsistent…
2
Answers
When you want to set
round
value, you don’t need to usedouble
but otherwise you need it.If you go inside the SizedBox you will see a Double waiting there. When you type 8, SizedBox treats it as 8.0 anyway.
Inside SizedBox it is