I'm making a list with some tiles containing texts, but they can't be big enough that it will break the layout. So I take only a substring from the text and add '...' to them to indicate there's more text hidden by the layout. Problem is, some texts are in caps lock and that makes the text have different sizes. Here is the sample code for the tile:
class _MessageTileState extends State<MessageTile> {
@override
Widget build(BuildContext context) {
final colorGrey = Theme.of(context).unselectedWidgetColor;
final screenSize = MediaQuery.of(context).size;
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
messageIcon(widget.message),
SizedBox(width: 16.0),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
widget.message.author.length > 38 ? widget.message.author.substring(0, 35) + '...' : widget.message.author,
style: TextStyle(
fontSize: screenSize.width * 0.033,
fontWeight: FontWeight.w600,
height: 1.6,
color: widget.message.read ? colorGrey : null,
),
),
Text(
widget.message.title.length > 38 ? widget.message.title.substring(0, 35) + '...' : widget.message.title,
style: TextStyle(
fontSize: screenSize.width * 0.033,
fontWeight: FontWeight.w600,
height: 1.6,
color: widget.message.read ? colorGrey : null,
),
),
Text(
widget.message.message.length > 38 ? widget.message.message.substring(0, 35).replaceAll('\n\n', ' ') + '...' : widget.message.message.replaceAll('\n\n', ' '),
style: TextStyle(
fontSize: screenSize.width * 0.033,
height: 1.6,
color: widget.message.read ? colorGrey : null,
),
),
Text(
DateFormat('MM/dd/yyyy - h:mm a').format(widget.message.date),
style: TextStyle(
fontSize: screenSize.width * 0.033,
fontWeight: FontWeight.w600,
color: colorGrey,
height: 1.6,
),
),
],
),
],
);
And here is a image showing the problem:
I want the text to occupy the same amount of space, regardless of being in uppercase or lowercase. (Making a simple check for upper or lower case doesn't work cause "there ARE TEXTS like THIS on those TILES" - different amount of lowercase and uppercase letters).
PS: Monospace font didn't work.
