flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

[Enhancement proposal]: throw UnsupportedError instead of UnimplementedError.

Open tlserver opened this issue 1 year ago • 0 comments

Please check the following before submitting a new issue.

Please select affected platform(s)

  • [ ] Android
  • [ ] iOS
  • [ ] Linux
  • [ ] macOS
  • [X] Web
  • [ ] Windows

Proposal

In the documentation for getServiceStatusStream(), it states:

Throws an UnimplementedError on the web, as the concept of location services does not exist on the web platform.

According to the Flutter documentation:

UnimplementedError class

Thrown by operations that have not been implemented yet.

This Error is thrown by unfinished code that has not yet implemented all the features it needs.

If the class does not intend to implement the feature, it should throw an UnsupportedError instead. This error is intended for use during development only.

Given this, I propose that getServiceStatusStream() should throw an UnsupportedError instead of an UnimplementedError.

Additionally, it should be noted that the documentation for GeolocatorPlatform.getServiceStatusStream() should be synchronized with Geolocator.getServiceStatusStream() to maintain consistency.

Related: #849

Pitch

Pitch: Refine Error Handling in getServiceStatusStream()

Enhancement

Switching from UnimplementedError to UnsupportedError in getServiceStatusStream() will provide clearer communication in the codebase, indicating that certain features will intentionally not be implemented on web platforms.

Benefits for Contributors

  • Clear Direction: Saves time by indicating which areas of the codebase are not intended for further development.
  • Consistency: Synchronizing documentation and error handling across related methods simplifies understanding and collaboration.
  • Code Quality: Aligns with Flutter's best practices, improving the overall project standard.

Impact

Adopting this change will:

  • Ensure clarity in development intentions.
  • Boost contributor efficiency and satisfaction.
  • Serve as a best practice example in the open-source community.

tlserver avatar Feb 07 '24 04:02 tlserver