const MyClass(int x, y) : _offset = Offset(x,y);
Does not work because the call context is not currently propagated into the constructor body.
Creating MyClass with const is different than creating it with new, but we can't pass that to Offset.
Putting const before Offset is invalid in the new context, and having (implicit) new is invalid in const context.
This might be changed in the future, and I saw there a quite a number of tickets with the tag enhanced-const.
The intuitive behaviour would be that Offset is const when MyClass is const.
See dart-lang/language#2000 (comment)
To me it feels natural to do something like
const a = A(value: 10);
const b = a.value;
This does not work since dart cant currently guarantee that value on A is a getter that returns a constant value:
class A { final int value; const A(this.value); }
final Random rng = Random()
class A2 implements A { get int value => rng.nextInt(); }
See dart-lang/language#1868 (comment) And also the proposal for stable getters, which seems like what one would expect to be the case already: dart-lang/language#1518
Cant use enum comparison in const expressions:
dart-lang/sdk#26980
dart-lang/language#1811