Skip to content

Conversation

@QuangNH0606
Copy link

@QuangNH0606 QuangNH0606 commented Jul 24, 2025

Fix: Type-safety and import conflict in google_maps_cluster_manager

Summary

This Pull Request fixes a runtime error in the google_maps_cluster_manager package caused by the usage of untyped cluster variables and ambiguous imports between cluster.dart and cluster_manager.dart.

The original code caused analyzer issues due to implicit Object? usage and type inference failures when accessing cluster.location, cluster.count, or cluster.isMultiple.

Related Issues

  • No official issue referenced, but this resolves a common runtime crash when using the package with Flutter 3.x and Dart null-safety.
  • Also addresses [Flutter analyzer error]: "The method 'location' isn't defined for the type 'Object?'".

Changes Introduced

  • Added generic typing to _basicMarkerBuilder<T> method.
  • Aliased imports of cluster.dart and cluster_manager.dart to avoid conflict.
  • Explicitly cast cluster to Cluster<T> before accessing typed members (location, isMultiple, count).
  • Ensured compatibility with Dart strong mode and current Flutter SDK.

Before (Problematic code)

final latLng = cluster.location; // ❌ Error: Object? has no method 'location'

@QuangNH0606 QuangNH0606 changed the title update local cluster Type-safety and import conflict in google_maps_cluster_manager Jul 24, 2025
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