Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@override of Dart code

I noticed PetitParserDart has a lot of @override in the code, but I don't know how do they be checked?

I tried IDEA dart-plugin for @override, but it has no effect at all. How can we use @override with Dart?

like image 471
Freewind Avatar asked Jul 09 '13 14:07

Freewind


1 Answers

From @override doc :

An annotation used to mark an instance member (method, field, getter or setter) as overriding an inherited class member. Tools can use this annotation to provide a warning if there is no overridden member.

So, it depends on the tool you use.

In the current Dart Editor(r24275), there's no warning for the following code but it should (it looks like a bug).

import 'package:meta/meta.dart';
class A {
  m1() {}
}
class B extends A {
  @override m1() {} // no warning because A has a m1()
  @override m2() {} // tools should display a warning because A has no m2()
}
like image 113
Alexandre Ardhuin Avatar answered Sep 21 '22 19:09

Alexandre Ardhuin