Skip to content

Refactor Flight and Checkout Modules - #11

Merged
VB10 merged 1 commit into
mainfrom
feature/v7.2_service_model
Mar 21, 2026
Merged

Refactor Flight and Checkout Modules#11
VB10 merged 1 commit into
mainfrom
feature/v7.2_service_model

Conversation

@VB10

@VB10 VB10 commented Mar 20, 2026

Copy link
Copy Markdown
Owner
  • Updated the Flight and Checkout response models to utilize JSON serialization with json_annotation and equatable for improved data handling and comparison.
  • Refactored the CartPage and FlightListPage to use a service layer for network requests, enhancing code organization and reducing redundancy.
  • Removed hardcoded URLs and replaced them with service calls, improving maintainability.
  • Cleaned up the ProfilePage to eliminate unnecessary API calls and streamline profile refreshing logic.
  • Removed outdated widget test file to declutter the test directory.

- Updated the Flight and Checkout response models to utilize JSON serialization with `json_annotation` and `equatable` for improved data handling and comparison.
- Refactored the CartPage and FlightListPage to use a service layer for network requests, enhancing code organization and reducing redundancy.
- Removed hardcoded URLs and replaced them with service calls, improving maintainability.
- Cleaned up the ProfilePage to eliminate unnecessary API calls and streamline profile refreshing logic.
- Removed outdated widget test file to declutter the test directory.
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the application's network communication and data modeling. By introducing a dedicated service layer and standardizing API response models, it enhances code organization, improves maintainability, and provides a more robust foundation for future feature development. The changes abstract away low-level network details, centralize error handling, and streamline data serialization, leading to a cleaner and more testable codebase.

Highlights

  • Network Layer Implementation: Introduced a comprehensive network and service layer using vexana, json_annotation, and equatable for robust API communication and data handling.
  • Model Refactoring: Updated Flight, Checkout, Login, and Profile response models to leverage json_annotation for automatic JSON serialization/deserialization and equatable for value comparison.
  • Service Layer Integration: Refactored CartPage, FlightListPage, and ProfilePage to utilize the new service layer for all network requests, eliminating direct Dio usage and hardcoded URLs.
  • Backend Error Standardization: Modified the backend server to return standardized error responses, including success, message, errorCode, and details fields, improving client-side error handling.
  • Automated Code Generation: Added build.yaml and a build_runner.sh script to automate the generation of JSON serialization code for models.
  • Integration Tests: Implemented integration tests for the new AuthService and FlightService to ensure the network layer functions correctly.
  • Documentation and Tooling: Added documentation for the network layer generator and updated Claude settings to support new development commands.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a major and well-executed refactoring that introduces a robust network and service layer using vexana, json_serializable, and equatable. The changes significantly improve code organization, maintainability, and testability by abstracting network calls away from the UI, removing hardcoded values, and introducing strongly-typed models. The addition of integration tests for the new services is also a great step towards a more reliable codebase.

I've found a few areas for improvement:

  • A critical syntax error in a generated file that will break the build.
  • An opportunity to improve type safety by passing model objects between widgets instead of raw maps.
  • A suggestion to use a dedicated request model for consistency in one of the service implementations.

Overall, this is a high-quality contribution that modernizes the application's architecture. Addressing the feedback will make it even better.

Comment on lines +20 to +22
'message': ?instance.message,
'errorCode': ?instance.errorCode,
'details': ?instance.details,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This file contains invalid Dart syntax. The ? prefix on the values in the map is not valid. It seems like there might have been an error when generating or copying this file's content.

Please re-run build_runner to generate the correct code. With include_if_null: false in your build.yaml, json_serializable should generate code that correctly handles nullable fields by omitting them from the JSON if they are null.

Comment on lines +129 to +131
final cartFlights = widget.cartItems
.map((item) => FlightModel.fromJson(item))
.toList();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This conversion from List<Map<String, dynamic>> back to List<FlightModel> indicates that it would be better to pass List<FlightModel> directly to CartPage from FlightListPage. This would improve type safety and avoid unnecessary serialization/deserialization between widgets.

I recommend refactoring FlightListPage to maintain a List<FlightModel> for the cart and pass that to CartPage. This would make your code cleaner and more robust.

Comment on lines +47 to +51
/// TODO: Request paramater
body: {
'cartItems': cartItems.map((item) => item.toJson()).toList(),
'userEmail': userEmail,
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The TODO comment here is a bit unclear. If it's suggesting an improvement, a good one would be to create a dedicated request model for the checkout body instead of building a Map inline. This improves type safety and consistency with your other models.

For example, you could create a CheckoutRequestModel:

@JsonSerializable()
final class CheckoutRequestModel {
  const CheckoutRequestModel({
    required this.cartItems,
    required this.userEmail,
  });

  final List<FlightModel> cartItems;
  final String userEmail;

  Map<String, dynamic> toJson() => _$CheckoutRequestModelToJson(this);
}

Then you could use it like this:
body: CheckoutRequestModel(cartItems: cartItems, userEmail: userEmail).toJson()

This makes the service implementation cleaner and the request structure more explicit.

@VB10 VB10 mentioned this pull request Mar 20, 2026
2 tasks
@VB10
VB10 merged commit 1f50ff8 into main Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant