By reading the documentation provided at the constructor section in Dart's language guide I understand that instance variables can be initialized in a initializer list. However, I don't see how it differs from initialization via formal parameters.
class Point {
final double x;
final double y;
// Compilation error because final fields must be set before the constructor body
Point.initializeFromBody(double x, double y) {
this.x = x;
this.y = y;
}
Point.initializeFromFormalParameter(this.x, this.y){
//...
}
Point.initializeFromList(double x, double y)
: this.x = x,
this.y = y {
//...
}
}
What are the benefits of using an initializer list that we don't have with the other two methods?