Skip to content

Files

Latest commit

 

History

History
30 lines (23 loc) · 661 Bytes

empty_constructor_bodies.md

File metadata and controls

30 lines (23 loc) · 661 Bytes

Pattern: Use of {} for empty constructor body

Issue: -

Description

In Dart, a constructor with an empty body can be terminated with just a semicolon. This is required for const constructors. For consistency and brevity, other constructors should also do this.

Example of correct code:

class Point {
 int x, y;
 Point(this.x, this.y);
}

Example of incorrect code:

class Point {
 int x, y;
 Point(this.x, this.y) {}
}

Further Reading