Skip to content

[leancode_markup] Default text style is lost with tagFactory #308

@RobertOdrowaz

Description

@RobertOdrowaz

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,
    ),
  );
},

Metadata

Metadata

Assignees

Labels

p: leancode_markupRelated to the leancode_markup pacakge

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions