0

class Foo {
  const Foo(this.message);
  final String message;
}

class Bar extends Foo {
  const Bar(String message, this.another,) : super(message); 
  final String another;
}

void main() {
  const Foo _foo = Bar('hello','world');
  const Bar _bar = _foo;
  print(_bar.another);
}

  • at the moment of writing, with darpad Based on Flutter 1.22.0-12.1.pre Dart SDK 2.9.3

    the output is world


this is the typical behavior that we experience with every Widget,

but is there a way to force the Object to lose the "extra" constructor

without recasting the whole Object?

Francesco Iapicca
  • 2,618
  • 5
  • 40
  • 85

1 Answers1

1

If nobody calls it, it will go away due to treeshaking.

Randal Schwartz
  • 39,428
  • 4
  • 43
  • 70