Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -980,11 +980,21 @@ class MarkdownBuilder implements md.NodeVisitor {
Widget _buildRichText(TextSpan text, {TextAlign? textAlign, String? key}) {
//Adding a unique key prevents the problem of using the same link handler for text spans with the same text
final Key k = key == null ? UniqueKey() : Key(key);
// Build strutStyle from paragraph style to enforce consistent line height across spans with different font weights.
final TextStyle? pStyle = styleSheet.p;
final StrutStyle? strutStyle = pStyle != null ? StrutStyle(
fontFamily: pStyle.fontFamily,
fontSize: pStyle.fontSize,
height: pStyle.height,
leading: 0,
forceStrutHeight: true,
) : null;
if (selectable) {
return SelectableText.rich(
text,
textScaler: styleSheet.textScaler,
textAlign: textAlign ?? TextAlign.start,
strutStyle: strutStyle,
onSelectionChanged: onSelectionChanged != null
? (TextSelection selection, SelectionChangedCause? cause) =>
onSelectionChanged!(text.text, selection, cause)
Expand All @@ -997,6 +1007,7 @@ class MarkdownBuilder implements md.NodeVisitor {
text,
textScaler: styleSheet.textScaler,
textAlign: textAlign ?? TextAlign.start,
strutStyle: strutStyle,
key: k,
);
}
Expand Down