Description
class Font {
final num size;
final FontFamily family;
final num weight;
final num lineHeight;
Font([num size, this.family, this.weight, num lineHeight]) :
this.size = size,
this.lineHeight = lineHeight == null ? (size * 1.2).round() : lineHeight;
}
I'd like the Font constructor to be:
Font([this.size, this.family, this.weight, num lineHeight]) :
this.lineHeight = lineHeight == null ? (size * 1.2).round() : lineHeight;
Where the this.size is assigned to the member variable then use size to compute this.lineHeight however, that isn't possible. Neither size or this.size can be used to access the instance variable in the initializer list. So I have to have a temporary for size then assign this.size = size then I can use size in the initializer list to compute this.lineHeight.
Activity
gbracha commentedon May 3, 2012
The design is very careful to ensure that no access to 'this' is possible in the initializers, so we can guarantee that uninitialized fields are not accessed. THis is an important property, but sometimes it means you have to type a little bit more.
Removed Type-Defect label.
Added Type-Enhancement, WontFix labels.
Cherry picks for pub
Bump pub
Revert "Bump pub"
Bump pub