Introduce @virtual
to allow field overrides in strong mode (SDK issue 27384).
import 'package:meta/meta.dart' show virtual; class Base { @virtual int x; } class Derived extends Base { int x; // Expose the hidden storage slot: int get superX => super.x; set superX(int v) { super.x = v; } }
Introduce @checked
to override a method and tighten a parameter type (SDK issue 25578).
import 'package:meta/meta.dart' show checked; class View { addChild(View v) {} } class MyView extends View { // this override is legal, it will check at runtime if we actually // got a MyView. addChild(@checked MyView v) {} } main() { dynamic mv = new MyView(); mv.addChild(new View()); // runtime error }
@visibleForTesting
annotation for declarations that may be referenced only in the library or in a test.@factory
to allow statics and methods returning null
.@protected
to include implemented interfaces (linter#252).@optionalTypeArgs
annotation for classes whose type arguments are to be treated as optional.Required
constructor with a means to specify a reason to explain why a parameter is required.@factory
annotation for methods that must either be abstract or must return a newly allocated object.@literal
annotation that indicates that any invocation of a constructor must use the keyword const
unless one or more of the arguments to the constructor is not a compile-time constant.@protected
annotation for members that must only be called from instance members of subclasses.@required
annotation for optional parameters that should be treated as required.@mustCallSuper
annotation for methods that must be invoked by all overriding methods.