Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Make all <a> tag clickable or fix alignment of extensions #1454

Open
EArminjon opened this issue Dec 11, 2024 · 1 comment
Open
Labels
enhancement New feature or request extensions

Comments

@EArminjon
Copy link
Contributor

EArminjon commented Dec 11, 2024

Describe your feature request

I want to know when a user tap on a tag even if the href is is empty or missing. By default, Html() make a tag not clickable when href is missing so i need to provide a custom extension.

Html(
  text: "Ship to: <a>75017</a> <a>PARIS</a>",
  extensions: <HtmlExtension>[
    TagWrapExtension(
      tagsToWrap: <String>{'a'},
      builder: (Widget child) {
        return GestureDetector(
          onTap: () {
            print('onTap');
          },
          child: child,
        );
      },
    ),
   ],
  'a': Style.fromTextStyle(
    context.texts.linkPrimary.copyWith(
      color: Color(0xFF2E4EAA),
    ), 
  ).copyWith(
    margin: Margins.zero,
    textDecoration: TextDecoration.none,
  ),
)

If i run this code this will display :

image

Instead of :

image

To bypass this issue, i used the bellow code, but that require an unsexy import and for more complexe scenario i will maybe be blocked later. :

// ignore: implementation_imports
import 'package:flutter_html/src/builtins/interactive_element_builtin.dart';

class InteractiveElementOverride extends InteractiveElementBuiltIn {
  const InteractiveElementOverride();

  @override
  bool matches(ExtensionContext context) =>
      supportedTags.contains(context.elementName);
}
/// ...
extensions: <HtmlExtension>[
  InteractiveElementOverride(),
],
/// ...

Additional context

flutter_html: 3.0.0-beta.2

@EArminjon EArminjon added the enhancement New feature or request label Dec 11, 2024
@Sub6Resources
Copy link
Owner

I added the verticalAlign property in 3.0.0 - does using baseline or middle for this fix your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request extensions
Projects
Status: Todo
Development

No branches or pull requests

2 participants