mapbox / mapbox/mapbox-maps-flutter

Can we have a nicer way to add click listener for annotations?

Open
#311 3 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dart
Stars
380
Forks
204
PR merge metrics
No merged PRs in 30d

Description

1. Instead of straight up doing the java way, implementing abstract classes for listener for annotations, why don't just use lambda since dart already supported much shorter syntax? Why would it have to be extra mile?
2. It should be able to setup click listener on the annotation class itself. For example:
It can be like this
```dart
final annotation = await circleAnnotationManager?.create(
CircleAnnotationOptions(
geometry: coordinate.toPoint().toJson(),
circleRadius: 10,
circleColor: Colors.orange.value,
),
);
annotation.setClickListener(() {
//...
})
```
or like this:
```dart
final annotation = await circleAnnotationManager?.create(
CircleAnnotationOptions(
geometry: coordinate.toPoint().toJson(),
circleRadius: 10,
circleColor: Colors.orange.value,
onClick: () {}
),
);
annotation.setClickListener(() {
//...
})
```
This way it would be much nicer.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the CircleAnnotationManager, CircleAnnotationOptions, and annotation objects used in the examples. Compare the existing annotation click-listener API with the requested callback forms, then define completion as supporting a simpler click callback on the created annotation or its options with appropriate behavior for CircleAnnotation.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.