title: Dart error, This constructor should initialize field 'x' because its type 'int' doesn't allow null
body: <p>I'm new to Dart. This is my code:</p>
  <pre><code>class Point {
    int x;
    int y;
  
    Point(this.x, this.y);
  
    Point.same(int i) {
      x = i;
      y = i;
    }
  }
  
  main() {}
  </code></pre>
  <p>I got this error when running it.</p>
  <pre><code>bin/dart1.dart:7:3: Error: This constructor should initialize field 'x' because its type 'int' doesn't allow null.
    Point.same(int i) {
    ^
  bin/dart1.dart:2:7: Context: 'x' is defined here.
    int x;
        ^
  bin/dart1.dart:7:3: Error: This constructor should initialize field 'y' because its type 'int' doesn't allow null.
    Point.same(int i) {
    ^
  bin/dart1.dart:3:7: Context: 'y' is defined here.
    int y;
        ^
  </code></pre>
  <p>As I understand, the parameter <code>int i</code> of <code>Point.same()</code> is non-nullable, and I use it to initialize <code>x</code> and <code>y</code> (<code>x = i; y = i;</code>). Why it still asks me to initialize <code>x</code> and <code>y</code>? I even tried the following code and still got the same error:</p>
  <pre><code>class Point {
    int x;
    int y;
  
    Point(this.x, this.y);
  
    Point.same() {
      x = 3;
      y = 3;
    }
  }
  
  main() {}
  </code></pre>