My previous patch caused an issue (which I could only reproduce
on Android): switching to Text inside WidgetSpan changed the way
the text appeared.
Two fixes are needed:
- Properly align the WidgetSpan Text with the InlineSpan
- Tell the WidgetSpan to render without scaling, otherwise the
text is scaled twice (once at Text time, and again in the
Text.rich when rendering the Widget). (I don't know why.)
Now the text is properly rendered and spaced.
---
lib/page/buffer.dart | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/page/buffer.dart b/lib/page/buffer.dart
index 323b960..7cbe496 100644
--- a/lib/page/buffer.dart+++ b/lib/page/buffer.dart
@@ -1,5 +1,6 @@
import 'dart:async';
+import 'package:flutter/cupertino.dart';import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
@@ -647,11 +648,13 @@ class _CompactMessageItem extends StatelessWidget {
child: Text(sender, style: senderStyle),
));
content.add(WidgetSpan(
+ alignment: PlaceholderAlignment.top, child: SelectionContainer.disabled(
child: Text(
sender,
style: senderStyle.apply(color: Color(0x00000000)),
semanticsLabel: '', // Make screen reader quiet
+ textScaler: TextScaler.noScaling, ),
),
));
@@ -671,11 +674,13 @@ class _CompactMessageItem extends StatelessWidget {
child: Text(timeText, style: timeStyle),
));
content.add(WidgetSpan(
+ alignment: PlaceholderAlignment.top, child: SelectionContainer.disabled(
child: Text(
timeText,
style: timeStyle.apply(color: Color(0x00000000)),
semanticsLabel: '', // Make screen reader quiet
+ textScaler: TextScaler.noScaling, ),
),
));
base-commit: 6dc63b850b80e21b7d9bd184cd3765e4b2b24954
--
2.44.0
Is cupertino.dart really needed here? Isn't there another import with
a smaller scope?
Sounds weird to import something for a completely separate theme.