Skip to content

Allow styleBuilder for LinkConfig #245

@maeddin

Description

@maeddin

Is your feature request related to a problem? Please describe.
Currently, LinkConfig only supports a static style for all links. This limits customization when different links need different styles (for example, external vs. internal links). I'm unable to dynamically adjust the text style based on the link target or content.

Describe the solution you'd like
Add a TextStyle? Function(String url)? styleBuilder property to LinkConfig.
When provided, styleBuilder should be called with the link URL to determine the style for that specific link.
If styleBuilder is not set, the existing style property should continue to be used as a fallback.
This would not be a breaking change, as it extends current behavior without modifying existing APIs.

Additional context
Example usage:

LinkConfig(
  styleBuilder: (url) {
    if (url.startsWith('https://internal.example.com')) {
      return const TextStyle(color: Colors.green);
    }
    return const TextStyle(color: Colors.blueAccent);
  },
)

This would allow flexible styling of links while preserving backward compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions