title: Dart: how to create a Final member Interface for Abstract Class
body: <p>I want to enforce a Class <code>User</code> to implement a static member from an abstract class <code>Base</code>. Is this possible, or am I using the abstract inheritance paradigm incorrectly?</p>
  
  <p>Without inheritance, the <code>User</code> can simply implement its own static member without overriding the <code>Base</code>, but I would like my linter to throw a warning when a Class does not implement some static member.</p>
  
  <h2>What works (without enforcing the interface)</h2>
  
  <p>We can implicitly use the same interface in <code>Base</code> and <code>User</code>.</p>
  
  <pre class="lang-dart prettyprint-override"><code>abstract class Base {
    // This member could simply be removed and the snippet would still compile.
    static final String routeName = '/base';
  }
  
  class User extends Base {
    static final String routeName = '/base/user';
  }
  </code></pre>
  
  <p>If we were to create a new Class <code>Person</code> that also extends <code>Base</code>, we have no specific implementation requirements. Ideally, I want to enforce <code>Person</code> to have a static member <code>routeName</code>.</p>
  
  <pre class="lang-dart prettyprint-override"><code>class Person extends Base {
    // No warning about a missing static member 'routeName'.
  }
  </code></pre>
  
  <h2>Example of the idea (does not compile)</h2>
  
  <p>The <code>Base</code> would contain an unimplemented static member (<code>routeName</code>).</p>
  
  <p>This snippet does not compile unless we specify the <code>routeName</code> (e.g. <code>routeName = '/base'</code>).</p>
  
  <pre class="lang-dart prettyprint-override"><code>abstract class Base {
    // IDE Error: The final variable 'routeName' must be initialized.
    static final String routeName;
  }
  </code></pre>
  
  <p>The <code>User</code> that implements <code>Base</code> would override or implement the static member.</p>
  
  <p>The snippet reports a warning, unless we remove the wrongly placed <code>@override</code>.</p>
  
  <pre class="lang-dart prettyprint-override"><code>class User extends Base {
    // IDE Warning: Field doesn't override an inherited getter or setter.
    @override
    static final String routeName = '/base/user';
  }
  </code></pre>
  
  <p>I want the IDE to throw an error for the <code>Person</code> Class since it does not implement the static member <code>routeName</code>.</p>
  
  <pre class="lang-dart prettyprint-override"><code>class Person extends Base {
    // Expected IDE Error: The static final variable 'routeName' must be initialized.
  }
  </code></pre>
  
  <p>To me, this looks similar to <a href="https://stackoverflow.com/questions/5667764/inheriting-static-variable-from-abstract-class?rq=1">how Java does it</a>, but I am unfamiliar with the Java specifics.</p>