Skip to content

Commit d9aeb69

Browse files
authored
feat: Added example network request with retrofit (#140)
1 parent 540a327 commit d9aeb69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+357
-129
lines changed

.run/Development Debug.run.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Development Debug" type="FlutterRunConfigurationType" factoryName="Flutter">
3+
<option name="additionalArgs" value="--dart-define-from-file=lib/config/dart_define_keys/dart_define_development_keys.json" />
4+
<option name="buildFlavor" value="development" />
5+
<option name="filePath" value="$PROJECT_DIR$/lib/main_development.dart" />
6+
<method v="2" />
7+
</configuration>
8+
</component>

.run/Development Release.run.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Development Release" type="FlutterRunConfigurationType" factoryName="Flutter">
3+
<option name="additionalArgs" value="--release --dart-define-from-file=lib/config/dart_define_keys/dart_define_development_keys.json" />
4+
<option name="buildFlavor" value="development" />
5+
<option name="filePath" value="$PROJECT_DIR$/lib/main_development.dart" />
6+
<method v="2" />
7+
</configuration>
8+
</component>
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Staging Debug" type="FlutterRunConfigurationType" factoryName="Flutter">
3+
<option name="additionalArgs" value="--dart-define-from-file=lib/config/dart_define_keys/dart_define_staging_keys.json" />
4+
<option name="buildFlavor" value="staging" />
35
<option name="filePath" value="$PROJECT_DIR$/lib/main_staging.dart" />
46
<method v="2" />
57
</configuration>
6-
</component>
8+
</component>
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Staging Release" type="FlutterRunConfigurationType" factoryName="Flutter">
3-
<option name="additionalArgs" value="--release" />
3+
<option name="additionalArgs" value="--release --dart-define-from-file=lib/config/dart_define_keys/dart_define_staging_keys.json" />
4+
<option name="buildFlavor" value="staging" />
45
<option name="filePath" value="$PROJECT_DIR$/lib/main_staging.dart" />
56
<method v="2" />
67
</configuration>
7-
</component>
8+
</component>

.run/development_debug.run.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.run/development_release.run.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,24 @@
99
"request": "launch",
1010
"type": "dart",
1111
"program": "lib/main_development.dart",
12-
"args": ["--flavor", "development"]
12+
"args": [
13+
"--flavor",
14+
"development",
15+
"--dart-define-from-file",
16+
"lib/config/dart_define_keys/dart_define_development_keys.json"
17+
]
1318
},
1419
{
1520
"name": "Staging",
1621
"request": "launch",
1722
"type": "dart",
1823
"program": "lib/main_staging.dart",
19-
"args": ["--flavor", "staging"]
24+
"args": [
25+
"--flavor",
26+
"staging",
27+
"--dart-define-from-file",
28+
"lib/config/dart_define_keys/dart_define_staging_keys.json"
29+
]
2030
}
21-
22-
// Commented to avoid running the product app from VSCode
23-
// Uncomment only if we really need it
24-
// {
25-
// "name": "Production",
26-
// "request": "launch",
27-
// "type": "dart",
28-
// "program": "lib/main_production.dart",
29-
// "args": [
30-
// "--flavor",
31-
// "production"
32-
// ]
33-
// },
3431
]
3532
}

.vscode/ml-flutter.code-snippets

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,63 @@
11
{
2-
"Freezed Class": {
3-
"prefix": "freezed",
4-
"body": [
5-
"import 'package:freezed_annotation/freezed_annotation.dart';",
6-
"",
7-
"part '${1:file}.freezed.dart';",
8-
"part '${1:file}.g.dart';",
9-
"",
10-
"@freezed",
11-
"class ${2:ClassName} with _$${2:ClassName} {",
12-
" const factory ${2:ClassName}({",
13-
" required ${0:param},",
14-
" }) = _${2:ClassName};",
15-
"",
16-
" factory ${2:ClassName}.fromJson(Map<String, dynamic> json) =>",
17-
" _$${2:ClassName}FromJson(json);",
18-
"}"
19-
],
20-
"description": "Creates basement for a freezed class."
21-
},
22-
}
2+
"Remote Data Source": {
3+
"prefix": "remote_data_source",
4+
"description": "Snippet for quick creation of a remote data source.",
5+
"body": [
6+
"import 'package:dio/dio.dart';",
7+
"import 'package:flutter_template/injection/network_module.dart';",
8+
"import 'package:injectable/injectable.dart';",
9+
"import 'package:retrofit/retrofit.dart';",
10+
"",
11+
"part '$TM_FILENAME_BASE.g.dart';",
12+
"",
13+
"@RestApi()",
14+
"@lazySingleton",
15+
"abstract class ${2:Scope}RemoteDataSource {",
16+
" @factoryMethod",
17+
" factory $2RemoteDataSource(",
18+
" @Named(dioAuthenticated) Dio dio,",
19+
" ) = _$2RemoteDataSource;",
20+
"",
21+
" ${3:/* Fill your calls here */}",
22+
"}",
23+
""
24+
]
25+
},
26+
"Freezed Class": {
27+
"prefix": "freezed",
28+
"body": [
29+
"import 'package:freezed_annotation/freezed_annotation.dart';",
30+
"",
31+
"part '${1:file}.freezed.dart';",
32+
"part '${1:file}.g.dart';",
33+
"",
34+
"@freezed",
35+
"class ${2:ClassName} with _$${2:ClassName} {",
36+
" const factory ${2:ClassName}({",
37+
" required ${0:param},",
38+
" }) = _${2:ClassName};",
39+
"",
40+
" factory ${2:ClassName}.fromJson(Map<String, dynamic> json) =>",
41+
" _$${2:ClassName}FromJson(json);",
42+
"}"
43+
],
44+
"description": "Creates basement for a freezed class."
45+
},
46+
"Remapper": {
47+
"prefix": "remapper",
48+
"description": "Create a basement for a remapper class.",
49+
"body": [
50+
"import 'package:injectable/injectable.dart';",
51+
"",
52+
"@lazySingleton",
53+
"class ${1:Entity}Remapper {",
54+
" ${1:Entity}Entity fromResponse(${1:Entity}Response response) {",
55+
" return ${1:Entity}Entity(",
56+
" ${2}",
57+
" );",
58+
" }",
59+
"",
60+
"}"
61+
]
62+
}
63+
}

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<uses-permission android:name="android.permission.INTERNET" />
23
<application
34
android:label="${appName}"
45
android:name="${applicationName}"

build.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ targets:
55
json_serializable:
66
options:
77
explicit_to_json: true
8-
# By deafult, field_rename: none, More options —
8+
# By default, field_rename: none, More options —
99
# snake, kebab, pascal, etc. To use, uncomment this below line —
1010
# field_rename: snake
1111
generate_for:
1212
include:
1313
# data layer:
1414
- lib/data/model/**.dart
15+
- lib/data/services/**_request.dart
16+
- lib/data/services/**_response.dart
1517
- lib/data/response_objects/**.dart
1618

1719
# domain layer:
@@ -20,13 +22,21 @@ targets:
2022
# We should not allow the entire `/entities` folder here, as entities don't need fromJson(), toJson(), etc.
2123
# Specifying exact file will help build runner to run fast.
2224
- lib/domain/entities/user.dart
25+
26+
# Retrofit Classes / Remote Data Sources
27+
retrofit_generator:
28+
generate_for:
29+
include:
30+
- lib/data/**/data_sources/remote/*_remote_data_source.dart
2331

2432
# Data Classes, Cloning
2533
freezed:freezed:
2634
generate_for:
2735
include:
2836
# data layer:
2937
- lib/data/model/**.dart
38+
- lib/data/services/**_request.dart
39+
- lib/data/services/**_response.dart
3040
- lib/data/response_objects/**.dart
3141

3242
# domain layer:
@@ -46,9 +56,12 @@ targets:
4656
generate_for:
4757
include:
4858
- lib/injection/injector.dart
59+
- lib/injection/modules/*_module.dart
4960

5061
# data
5162
- lib/data/**_config.dart
63+
- lib/data/**_client.dart
64+
- lib/data/**/data_sources/remote/*_remote_data_source.dart
5265
- lib/data/services/**_service_impl.dart
5366
- lib/data/services/**_remapper.dart
5467
- lib/data/preferences/**_preferences.dart

0 commit comments

Comments
 (0)