-
Notifications
You must be signed in to change notification settings - Fork 46
Implement Roadster #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7695161
Add network_roadster_model
ashtanko 16308c6
Add roadster service
ashtanko 809ae18
Add roadster resource
ashtanko 50bc331
Add roadster repository
ashtanko 7767312
Add roadster bloc
ashtanko 8721531
WIP Add roadster screen
ashtanko aba1122
Small refactor + add unit tests
ashtanko b707fc3
Add unit tests
ashtanko efe7817
Fix integration tests
ashtanko 2590bc0
Refactor colors + fix some unit tests
ashtanko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
26 changes: 26 additions & 0 deletions
26
lib/data/network/data_source/roadster_network_data_source.dart
This file contains hidden or 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,26 @@ | ||
| import 'package:dio/dio.dart'; | ||
| import 'package:flutter_bloc_app_template/data/network/api_result.dart'; | ||
| import 'package:flutter_bloc_app_template/data/network/model/roadster/network_roadster_model.dart'; | ||
| import 'package:flutter_bloc_app_template/data/network/service/roadster/roadster_service.dart'; | ||
|
|
||
| abstract class RoadsterDataSource { | ||
| Future<ApiResult<NetworkRoadsterModel>> getRoadster(); | ||
| } | ||
|
|
||
| class RoadsterNetworkDataSource implements RoadsterDataSource { | ||
| RoadsterNetworkDataSource(this._service); | ||
|
|
||
| final RoadsterService _service; | ||
|
|
||
| @override | ||
| Future<ApiResult<NetworkRoadsterModel>> getRoadster() async { | ||
| try { | ||
| final result = await _service.fetchRoadster(); | ||
| return ApiResult.success(result); | ||
| } on DioException catch (e) { | ||
| return ApiResult.error(e.message ?? e.toString()); | ||
| } catch (e) { | ||
| return Future.value(ApiResult.error(e.toString())); | ||
| } | ||
| } | ||
| } | ||
12 changes: 0 additions & 12 deletions
12
lib/data/network/model/core/network_core_model.freezed.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
lib/data/network/model/roadster/network_roadster_model.dart
This file contains hidden or 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,42 @@ | ||
| import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
|
||
| part 'network_roadster_model.freezed.dart'; | ||
| part 'network_roadster_model.g.dart'; | ||
|
|
||
| @freezed | ||
| abstract class NetworkRoadsterModel with _$NetworkRoadsterModel { | ||
| const factory NetworkRoadsterModel({ | ||
| String? name, | ||
| @JsonKey(name: 'launch_date_utc') String? launchDateUtc, | ||
| @JsonKey(name: 'launch_date_unix') int? launchDateUnix, | ||
| @JsonKey(name: 'launch_mass_kg') int? launchMassKg, | ||
| @JsonKey(name: 'launch_mass_lbs') int? launchMassLbs, | ||
| @JsonKey(name: 'norad_id') int? noradId, | ||
| @JsonKey(name: 'epoch_jd') double? epochJd, | ||
| @JsonKey(name: 'orbit_type') String? orbitType, | ||
| @JsonKey(name: 'apoapsis_au') double? apoapsisAu, | ||
| @JsonKey(name: 'periapsis_au') double? periapsisAu, | ||
| @JsonKey(name: 'semi_major_axis_au') double? semiMajorAxisAu, | ||
| double? eccentricity, | ||
| double? inclination, | ||
| double? longitude, | ||
| @JsonKey(name: 'periapsis_arg') double? periapsisArg, | ||
| @JsonKey(name: 'period_days') double? periodDays, | ||
| @JsonKey(name: 'speed_kph') double? speedKph, | ||
| @JsonKey(name: 'speed_mph') double? speedMph, | ||
| @JsonKey(name: 'earth_distance_km') double? earthDistanceKm, | ||
| @JsonKey(name: 'earth_distance_mi') double? earthDistanceMi, | ||
| @JsonKey(name: 'mars_distance_km') double? marsDistanceKm, | ||
| @JsonKey(name: 'mars_distance_mi') double? marsDistanceMi, | ||
| @JsonKey(name: 'flickr_images') List<String>? flickrImages, | ||
| String? wikipedia, | ||
| String? video, | ||
| String? details, | ||
| String? id, | ||
| }) = _NetworkRoadsterModel; | ||
|
|
||
| const NetworkRoadsterModel._(); | ||
|
|
||
| factory NetworkRoadsterModel.fromJson(Map<String, dynamic> json) => | ||
| _$NetworkRoadsterModelFromJson(json); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Tighten error handling and remove unnecessary Future.value
Catch DioException explicitly and return error without wrapping in Future.value.
Also applies to: 14-21
🤖 Prompt for AI Agents