|
4 | 4 |
|
5 | 5 | - When generating new Dart code, strictly follow the style conventions defined in [Effective Dart](https://dart.dev/effective-dart). |
6 | 6 | - Systematically prefer using `const` constructors and literals whenever possible to optimize runtime performance. |
| 7 | +- Prefer using the Dart MCP tool instead of running commands manually. |
7 | 8 |
|
8 | 9 | ## Comments, Documentation and Examples |
9 | 10 |
|
|
27 | 28 |
|
28 | 29 | ### Code Quality |
29 | 30 |
|
30 | | -- The code must be free of linter warnings (run `dart analyze` and `dart fix --apply`). |
31 | 31 | - The code must be auto-formatted (run `dart format .`). |
32 | | -- Embrace strict **null safety**. Avoid using the non-null assertion operator (`!`) unless you can prove adherence to a loop invariant or similar logical guarantee that the compiler cannot infer. |
| 32 | +- The code must be free of linter warnings (run `dart analyze` and `dart fix --apply`). |
| 33 | +- Embrace strict null safety. Avoid using the non-null assertion operator (`!`) or `dynamic` types, if possible. |
33 | 34 |
|
34 | 35 | ## Logic and Patterns |
35 | 36 |
|
36 | 37 | ### Asynchrony |
37 | 38 |
|
38 | | -- Prefer `async` / `await` syntax over chaining `Future.then`, `Future.catchError`, etc., for better readability. |
39 | | -- Always return `Future<void>` instead of `void` for asynchronous functions (unless it's an event handler where `void` is required). |
| 39 | +- Prefer `async` / `await` syntax over chaining `Future.then`, `Future.catchError`, ... |
| 40 | +- Always return `Future<void>` instead of `void` for asynchronous functions. |
40 | 41 |
|
41 | 42 | ### Error Handling |
42 | 43 |
|
43 | | -- Throw specific exceptions (e.g., `ArgumentError`, `StateError`, `FormatException`) rather than generic `Exception` strings. |
| 44 | +- Throw specific exceptions (e.g., `ArgumentError`, `StateError`, `FormatException`) rather than generic `Exception`. |
44 | 45 | - Catch specific exceptions. Avoid generic `catch (e)` unless you are logging the error or rethrowing it. |
45 | 46 |
|
46 | 47 | ## Architecture |
47 | 48 |
|
48 | 49 | - Keep the root `lib/` directory clean. It should primarily contain the public API exports. |
49 | 50 | - Place implementation details in `lib/src/`. Users of the package should not import files from `lib/src/` directly. |
50 | | -- Avoid introducing new external dependencies in `pubspec.yaml` unless absolutely necessary and no alternative exists in the SDK. If required, justify the addition to the user. |
| 51 | +- Avoid introducing new external dependencies in `pubspec.yaml` unless absolutely necessary and no alternative exists in the SDK. Justify any addition to the user. |
51 | 52 |
|
52 | 53 | ## Testing |
53 | 54 |
|
|
0 commit comments