Skip to content

The package must export html/dom to satisfy onLinkTap being acceptable #1178

@darkstarx

Description

@darkstarx
typedef OnTap = void Function(
  String? url,
  RenderContext context,
  Map<String, String> attributes,
  dom.Element? element,
);
...
  /// A function that defines what to do when a link is tapped
  final OnTap? onLinkTap;

Dart allow to use methods but not only closures in functional properties. So I can write such code

Html(
  data: snapshot.data,
  style: htmlStyle,
  onLinkTap: onLinkType,
),
...
void onLinkType(
  String? url,
  RenderContext context,
  Map<String, String> attributes,
  dom.Element? element,
) {
...
}

And I have to put the html dependency in my project's pubspec.yaml just to be able to use method instead of closure. That's unacceptable.
This is the same mistake as the one described here https://dart-lang.github.io/linter/lints/library_private_types_in_public_api.html

As a solution you can write export 'package:html/dom.dart' as dom; in the flutter_html.dart.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

Status

Todo

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions