Skip to content

Replace LayerHitNotifier alias with a type extension #2115

@JaffaKetchup

Description

@JaffaKetchup

What do you want implemented?

Using a type extension instead of a typedef is a good quality-of-life improvement, although breaking.

Here's what it could look like:

extension type LayerHitNotifier<R extends Object>._(
        ValueNotifier<LayerHitResult<R>?> notifier)
    implements ValueNotifier<LayerHitResult<R>?> {
  LayerHitNotifier() : this._(ValueNotifier(null));

  @internal
  @redeclare
  set value(LayerHitResult<R>? v) => notifier.value = v;
}

Creating a notifier becomes more self explanatory:

- final LayerHitNotifier<Object> hitNotifier = ValueNotifier(null);
+ final hitNotifier = LayerHitNotifier<Object>();

Trying to externally set its value (which is not necessary) can be discouraged by the @internal annotation which causes a linting warning.

What other alternatives are available?

No response

Can you provide any other information?

No response

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions