Skip to content

refactor: Add error handling and optimize marker/camera operations #251

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

berhili098
Copy link

@berhili098 berhili098 commented Jan 20, 2025

This pull request primarily focuses on enhancing error handling and code organization in the example/lib/pages/camera.dart and example/lib/pages/markers.dart files. The most important changes include adding try-catch blocks for error handling, refactoring camera movement logic into a helper method, and improving marker management.

Error Handling Enhancements:

  • Added try-catch blocks to the _startNavigation, _stopNavigation, dispose, and calculateFocusCenter methods to handle potential errors and display appropriate messages. [1] [2] [3]
  • Introduced error handling in marker management methods such as addMarkerToMap, _removeMarker, clearMarkers, _updateSelectedMarkerWithOptions, _toggleCustomIcon, and dispose to ensure robust error messages are shown. [1] [2]

Code Organization Improvements:

  • Refactored camera movement logic into a new helper method _moveCameraWithAnimation to reduce code duplication and improve readability. [1] [2] [3] [4] [5] [6] [7] [8]
  • Consolidated marker property updates into a single helper method _updateMarkerProperty to streamline the code and reduce redundancy.

These changes collectively enhance the robustness and maintainability of the codebase.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

…mera and markers pages

- Improved error handling in navigation and marker operations, providing user feedback on failures.
- Refactored marker management methods to reduce code duplication and improve readability.
- Added try-catch blocks to handle potential exceptions during navigation and marker updates.
- Introduced a helper method for updating marker properties, streamlining the process of toggling visibility, draggable state, and other attributes.
- Ensured proper cleanup of resources during disposal to prevent memory leaks.

These changes enhance the robustness and maintainability of the camera and markers functionality.
@jokerttu
Copy link
Contributor

@berhili098
Thanks for your contribution!
I'll review the PR in the next few days.

@jokerttu jokerttu self-requested a review February 10, 2025 15:13
@illuminati1911
Copy link
Contributor

Hi @berhili098, thanks for your contribution!

When it comes to the example application, we prioritize code readability over exhaustive error handling. Our main goal is to keep the code examples easy to read and quick to understand, rather than covering every possible error scenario. In many cases, the errors thrown by the SDK are theoretical and should not occur if the functions are used correctly.

Additionally, if we were to introduce this level of error handling in the example app, it would need to be implemented consistently across all pages and not just the camera and marker pages. Also, when catching exceptions, the specific exception type should be specified in the catch block.

While using our SDK, did you encounter a specific error scenario that you're trying to resolve with this PR?

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.

3 participants