-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved melos example with common package and todo list
- Loading branch information
Showing
15 changed files
with
216 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
examples/dartness_flutter_melos/commons/lib/todo_list_response.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:my_common/todo_response.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'todo_list_response.g.dart'; | ||
|
||
@JsonSerializable() | ||
class TodoListResponse { | ||
List<TodoResponse> todos; | ||
int total; | ||
int skip; | ||
int limit; | ||
|
||
TodoListResponse({ | ||
required this.todos, | ||
required this.total, | ||
required this.skip, | ||
required this.limit, | ||
}); | ||
|
||
factory TodoListResponse.fromJson(Map<String, dynamic> json) => | ||
_$TodoListResponseFromJson(json); | ||
|
||
Map<String, dynamic> toJson() => _$TodoListResponseToJson(this); | ||
} |
25 changes: 25 additions & 0 deletions
25
examples/dartness_flutter_melos/commons/lib/todo_list_response.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
examples/dartness_flutter_melos/commons/lib/todo_response.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'todo_response.g.dart'; | ||
|
||
@JsonSerializable() | ||
class TodoResponse { | ||
int id; | ||
String todo; | ||
bool completed; | ||
int userId; | ||
|
||
TodoResponse({ | ||
required this.id, | ||
required this.todo, | ||
required this.completed, | ||
required this.userId, | ||
}); | ||
|
||
factory TodoResponse.fromJson(Map<String, dynamic> json) => | ||
_$TodoResponseFromJson(json); | ||
|
||
Map<String, dynamic> toJson() => _$TodoResponseToJson(this); | ||
} |
22 changes: 22 additions & 0 deletions
22
examples/dartness_flutter_melos/commons/lib/todo_response.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: my_common | ||
description: A sample dartness server. | ||
version: 1.0.0 | ||
# homepage: https://www.example.com | ||
|
||
publish_to: "none" | ||
|
||
environment: | ||
sdk: ">=3.0.0 <4.0.0" | ||
|
||
dev_dependencies: | ||
json_serializable: ^6.7.1 | ||
build_runner: ^2.4.6 |
17 changes: 15 additions & 2 deletions
17
examples/dartness_flutter_melos/servers/my_server/lib/app.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
examples/dartness_flutter_melos/servers/my_server/lib/app.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...ers/my_server/lib/example_controller.dart → ...my_server/lib/hello_world_controller.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/my_server/lib/example_controller.g.dart → ..._server/lib/hello_world_controller.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
examples/dartness_flutter_melos/servers/my_server/lib/todos_controller.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:dartness_server/route.dart'; | ||
import 'package:dio/dio.dart'; | ||
import 'package:my_common/todo_list_response.dart'; | ||
import 'dart:math'; | ||
|
||
part 'todos_controller.g.dart'; | ||
|
||
@Controller('/todos') | ||
@Header(HttpHeaders.contentTypeHeader, 'application/json') | ||
class TodosController { | ||
final Dio _dio; | ||
|
||
TodosController(this._dio); | ||
|
||
@Get() | ||
Future<TodoListResponse> getTodos() async { | ||
var rng = Random(); | ||
final userId = rng.nextInt(6); | ||
final result = await _dio.get('https://dummyjson.com/todos/user/$userId'); | ||
return TodoListResponse.fromJson(result.data); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
examples/dartness_flutter_melos/servers/my_server/lib/todos_controller.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters