leancodepl / leancodepl/flutter_corelibrary

[leancode_markup] Default text style is lost with `tagFactory`

Open
#308 0 comments 1 reaction 1 assignee View on GitHub

@pdenert is already working on this.

Since Jun 21, 2024.

p: leancode_markup
Dominant language
Dart
Stars
89
Forks
12
Avg merge
2d 7h
Merged PRs (30d)
2

Description

When adding a custom url tag I had to force it a little to get correct link style and alignment with the rest of the text.

  1. I had to provide modified default style in tagStyles
MarkupTagStyle.delegate(
  tagName: 'a',
  styleCreator: (_) => style.copyWith( // Here I needed a copy the `style` because the `DefaultTextStyle` provided above wasn't used for the link span
    fontWeight: FontWeight.bold,
    color: linkColor ?? colors.primary,
  ),
),

I would expect to just need to provide empty text style with the desired properties as is the case for bold tag

MarkupTagStyle.delegate(
  tagName: 'b',
  styleCreator: (_) => const TextStyle(fontWeight: FontWeight.bold),
),
  1. I had to add some arguments in WidgetSpan to get proper alignment of the link text. I don't know if we can fix this in the package, maybe we just should include this in the readme/example.
'a': (child, parameter) {
  return WidgetSpan(
    baseline: TextBaseline.alphabetic, // here
    alignment: PlaceholderAlignment.baseline, // and here
    child: GestureDetector(
      onTap: () async {
        if (parameter != null) {
          await alxLaunchUrl(url: parameter);
        }
      },
      child: child,
    ),
  );
},

Contributor guide

No contributing guide indexed for this repository

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.