Skip to content

Commit c7c641c

Browse files
DiRuffyJochum van der Ploegalestiago
authored
docs: add missing typecasting to the todos tutorial (#1226)
Co-authored-by: Jochum van der Ploeg <[email protected]> Co-authored-by: Alejandro Santiago <[email protected]>
1 parent 9143f18 commit c7c641c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

docs/docs/tutorials/todos.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,9 @@ Future<Response> _get(RequestContext context) async {
532532
533533
Future<Response> _post(RequestContext context) async {
534534
final dataSource = context.read<TodosDataSource>();
535-
final todo = Todo.fromJson(await context.request.json());
535+
final todo = Todo.fromJson(
536+
await context.request.json() as Map<String, dynamic>,
537+
);
536538
537539
return Response.json(
538540
statusCode: HttpStatus.created,
@@ -599,7 +601,9 @@ Future<Response> _get(RequestContext context, Todo todo) async {
599601
600602
Future<Response> _put(RequestContext context, String id, Todo todo) async {
601603
final dataSource = context.read<TodosDataSource>();
602-
final updatedTodo = Todo.fromJson(await context.request.json());
604+
final updatedTodo = Todo.fromJson(
605+
await context.request.json() as Map<String, dynamic>,
606+
);
603607
final newTodo = await dataSource.update(
604608
id,
605609
todo.copyWith(

0 commit comments

Comments
 (0)