-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added example network request with retrofit (#140)
- Loading branch information
1 parent
540a327
commit d9aeb69
Showing
41 changed files
with
357 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Development Debug" type="FlutterRunConfigurationType" factoryName="Flutter"> | ||
<option name="additionalArgs" value="--dart-define-from-file=lib/config/dart_define_keys/dart_define_development_keys.json" /> | ||
<option name="buildFlavor" value="development" /> | ||
<option name="filePath" value="$PROJECT_DIR$/lib/main_development.dart" /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
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,8 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Development Release" type="FlutterRunConfigurationType" factoryName="Flutter"> | ||
<option name="additionalArgs" value="--release --dart-define-from-file=lib/config/dart_define_keys/dart_define_development_keys.json" /> | ||
<option name="buildFlavor" value="development" /> | ||
<option name="filePath" value="$PROJECT_DIR$/lib/main_development.dart" /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Staging Debug" type="FlutterRunConfigurationType" factoryName="Flutter"> | ||
<option name="additionalArgs" value="--dart-define-from-file=lib/config/dart_define_keys/dart_define_staging_keys.json" /> | ||
<option name="buildFlavor" value="staging" /> | ||
<option name="filePath" value="$PROJECT_DIR$/lib/main_staging.dart" /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> | ||
</component> |
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Staging Release" type="FlutterRunConfigurationType" factoryName="Flutter"> | ||
<option name="additionalArgs" value="--release" /> | ||
<option name="additionalArgs" value="--release --dart-define-from-file=lib/config/dart_define_keys/dart_define_staging_keys.json" /> | ||
<option name="buildFlavor" value="staging" /> | ||
<option name="filePath" value="$PROJECT_DIR$/lib/main_staging.dart" /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> | ||
</component> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
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 |
---|---|---|
@@ -1,22 +1,63 @@ | ||
{ | ||
"Freezed Class": { | ||
"prefix": "freezed", | ||
"body": [ | ||
"import 'package:freezed_annotation/freezed_annotation.dart';", | ||
"", | ||
"part '${1:file}.freezed.dart';", | ||
"part '${1:file}.g.dart';", | ||
"", | ||
"@freezed", | ||
"class ${2:ClassName} with _$${2:ClassName} {", | ||
" const factory ${2:ClassName}({", | ||
" required ${0:param},", | ||
" }) = _${2:ClassName};", | ||
"", | ||
" factory ${2:ClassName}.fromJson(Map<String, dynamic> json) =>", | ||
" _$${2:ClassName}FromJson(json);", | ||
"}" | ||
], | ||
"description": "Creates basement for a freezed class." | ||
}, | ||
} | ||
"Remote Data Source": { | ||
"prefix": "remote_data_source", | ||
"description": "Snippet for quick creation of a remote data source.", | ||
"body": [ | ||
"import 'package:dio/dio.dart';", | ||
"import 'package:flutter_template/injection/network_module.dart';", | ||
"import 'package:injectable/injectable.dart';", | ||
"import 'package:retrofit/retrofit.dart';", | ||
"", | ||
"part '$TM_FILENAME_BASE.g.dart';", | ||
"", | ||
"@RestApi()", | ||
"@lazySingleton", | ||
"abstract class ${2:Scope}RemoteDataSource {", | ||
" @factoryMethod", | ||
" factory $2RemoteDataSource(", | ||
" @Named(dioAuthenticated) Dio dio,", | ||
" ) = _$2RemoteDataSource;", | ||
"", | ||
" ${3:/* Fill your calls here */}", | ||
"}", | ||
"" | ||
] | ||
}, | ||
"Freezed Class": { | ||
"prefix": "freezed", | ||
"body": [ | ||
"import 'package:freezed_annotation/freezed_annotation.dart';", | ||
"", | ||
"part '${1:file}.freezed.dart';", | ||
"part '${1:file}.g.dart';", | ||
"", | ||
"@freezed", | ||
"class ${2:ClassName} with _$${2:ClassName} {", | ||
" const factory ${2:ClassName}({", | ||
" required ${0:param},", | ||
" }) = _${2:ClassName};", | ||
"", | ||
" factory ${2:ClassName}.fromJson(Map<String, dynamic> json) =>", | ||
" _$${2:ClassName}FromJson(json);", | ||
"}" | ||
], | ||
"description": "Creates basement for a freezed class." | ||
}, | ||
"Remapper": { | ||
"prefix": "remapper", | ||
"description": "Create a basement for a remapper class.", | ||
"body": [ | ||
"import 'package:injectable/injectable.dart';", | ||
"", | ||
"@lazySingleton", | ||
"class ${1:Entity}Remapper {", | ||
" ${1:Entity}Entity fromResponse(${1:Entity}Response response) {", | ||
" return ${1:Entity}Entity(", | ||
" ${2}", | ||
" );", | ||
" }", | ||
"", | ||
"}" | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// This class is declared as an `abstract interface` to restrict inheritance | ||
// and prevent instantiation outside the library. | ||
abstract interface class DartDefine { | ||
static const apiBaseUrl = String.fromEnvironment('API_BASE_URL'); | ||
} |
3 changes: 3 additions & 0 deletions
3
lib/config/dart_define_keys/dart_define_development_keys.json
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,3 @@ | ||
{ | ||
"API_BASE_URL": "https://randomuser.me" | ||
} |
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,3 @@ | ||
{ | ||
"API_BASE_URL": "https://randomuser.me" | ||
} |
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,3 @@ | ||
{ | ||
"API_BASE_URL": "https://randomuser.me" | ||
} |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import 'package:injectable/injectable.dart'; | ||
|
||
@Injectable() | ||
/// A configuration class providing properties specific to an API. | ||
/// | ||
/// Class instance is registered via [ApiConfigModule]. | ||
class ApiConfig { | ||
final String baseUrl; | ||
ApiConfig({ | ||
required this.baseUrl, | ||
}); | ||
|
||
ApiConfig(this.baseUrl); | ||
final String baseUrl; | ||
|
||
String get apiUrl => '$baseUrl/api'; | ||
} |
7 changes: 4 additions & 3 deletions
7
...services/http_client/dio_http_client.dart → ...ata/core/http_client/dio_http_client.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
.../http_client/dio_http_client_builder.dart → .../http_client/dio_http_client_builder.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
File renamed without changes.
10 changes: 5 additions & 5 deletions
10
lib/data/interceptor/auth_interceptor.dart → lib/data/interceptors/auth_interceptor.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
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
19 changes: 19 additions & 0 deletions
19
lib/data/services/profile/data_sources/remote/profile_remote_data_source.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,19 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:flutter_template/data/services/profile/dtos/profile_response.dart'; | ||
import 'package:flutter_template/injection/modules/network_module.dart'; | ||
import 'package:injectable/injectable.dart'; | ||
import 'package:retrofit/retrofit.dart'; | ||
|
||
part 'profile_remote_data_source.g.dart'; | ||
|
||
@RestApi() | ||
@lazySingleton | ||
abstract class ProfileRemoteDataSource { | ||
@factoryMethod | ||
factory ProfileRemoteDataSource( | ||
@Named(dioAuthenticated) Dio dio, | ||
) = _ProfileRemoteDataSource; | ||
|
||
@GET('/') | ||
Future<ProfileResponse> getProfile(); | ||
} |
Oops, something went wrong.