uix
uix copied to clipboard
Wrong private fields on Component class
trafficstars
This
/// Protected property that contains data input.
P data_;
/// Protected property that contains children input.
List<VNode> children_;
should be like this
/// Protected property that contains data input.
P _data;
/// Protected property that contains children input.
List<VNode> _children;
Wrong side of the underscore for private fields.
They are "protected", not private. Dart doesn't support protected properties, so I just added _ suffix to make it possible to reuse them when overriding data setter, for example:
class LineView extends Component<RichLine> {
List<VNode> _fragments;
set data(RichLine newData) {
if (identical(data, newData)) {
if (data.isNewer(this)) {
invalidate();
}
} else {
data_ = newData;
invalidate();
}
}
...
}