From the Effective Dart: usage, you can see the following example:
Basically, any place where it would be an error to write new instead of const, Dart 2 allows you to omit the const.
Good:
const primaryColors = [
Color("red", [255, 0, 0]),
Color("green", [0, 255, 0]),
Color("blue", [0, 0, 255]),
];
Bad:
const primaryColors = const [
const Color("red", const [255, 0, 0]),
const Color("green", const [0, 255, 0]),
const Color("blue", const [0, 0, 255]),
];
Using your example, and reading the Edge Insets documentation you can see that the symmetric
constructor is a const constructor:
const EdgeInsets.symmetric(
{double vertical: 0.0,
double horizontal: 0.0}
)
So the const in this case is optional and recommended to be ommited from the Dart Guidelines.
So, answering your question:
If so, why?
It isn't. It's optional and makes it redundant to read, so it's better to be ommited.
Does it depend on which element(s) is/are most likely to recur in the program, and hence be canonicalized?
You should use for things that are compile time constants, i.e you can figure it's whole value without having to run the program.
If you can assure that, you can add const to the constructor of a function you declared, or a value you created. In this way, the compiler can assign a "nickname" to that object and will not need to recreate it everytime it's needed.