Skip to content

Commit 1cfc303

Browse files
authored
docs(routes): add warning about build_runner and using lib (#321)
1 parent 31642ca commit 1cfc303

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

β€Ždocs/docs/basics/routes.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,21 @@ Response onRequest(RequestContext context) {
6363
We can also return any Dart object in the `body` of the `Response.json` constructor and it will be serialized correctly as long as it has a `toJson` method that returns a `Map<String, dynamic>`.
6464

6565
:::tip
66-
Check out [json_serializable](https://pub.dev/packages/json_serializable) to automate the `toJson` generation.
66+
Check out [`json_serializable`](https://pub.dev/packages/json_serializable) to automate the `toJson` generation.
67+
:::
68+
69+
:::caution
70+
`json_serializable` uses [`build_runner`](https://pub.dev/packages/build_runner) which expects code to be within the `lib` directory. In order for the code generation step to work, make sure the `User` model below is located somewhere within the top level `lib` directory.
71+
72+
For example:
73+
74+
```
75+
β”œβ”€β”€ lib
76+
β”‚ └── models
77+
β”‚ └── user.dart
78+
└── routes
79+
```
80+
6781
:::
6882

6983
```dart

0 commit comments

Comments
Β (0)