Flutter ellipsis broken when using a custom font - flutter

I have an issue. I am using the Oxygen font from Google Fonts (Oxygen-Regular.ttf) and when I use:
child: Text(
item.name,
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
style: TextStyle(
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.left,
),
The display of ellipsis gets really weird, a small square appears:
Whereas when I use the default font of the flutter app, ... three dots appear, as I want. So, how can I solve this issue?

Related

Show Tooltip just when text is trimmed because of overflow

I am displaying Tooltip on top of a Text, letting user see the full name of person, but it shows Tooltip, either when text has overflown or not:
child: Tooltip(
message: fullNameWithTitle,
child: Text(
fullNameWithTitle,
style: const TextStyle(
color: Colors.white,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
),
),
But how can I set Tooltip in such a way that displays just if text is trimmed by ellipsis?

Flutter Text overflow

How to control TextOverFlow if don't know the const width of the box.
I know about
Text(
'some Text',
overflow: TextOverflow.ellipsis,
)
but is there any way to wrap widgets like expanded or flexible?
FittedBox(
fit: setToWidth ? BoxFit.contain : BoxFit.none,
child: Text(
displayText,
maxLines: 2,
textAlign: textAlign,
style: setToWidth
? TextStyle(
fontWeight: fontWeight,
color: textColor,
fontFamily: AppFonts.circularStd,
)
: TextStyle(
fontWeight: fontWeight,
color: textColor,
fontFamily: AppFonts.circularStd,
fontSize: textSize),
),
);
Try with this
You can try AutoSizeText instead.
https://pub.dev/packages/auto_size_text
Note: it'll increase your overall app size as it requires external dependencies. But it'll give you some extra features such as maxLines and minLines. I will suggest read more about it.

flutter listTile with a long text for the Title

I have a listTile title with a long text .
I whoud like the title to show as must text as possible , in one single line ...
If I use softWrap: true, overflow: TextOverflow.ellipsis, the text is cut after 4 caracter´s
like : exampl....
if I don´t use softWrap: true, overflow: TextOverflow.ellipsis, the text is shown in 3 or 4 lines
I tryied using FittedBox , but the text get´s really small .. unreadable ....
Any ideias how to get this ?
title: Text(
inc.descricao,
style: TextStyle(
color: Colors.white,
fontFamily: "Roboto",
fontSize: 16,
),
softWrap: true,
overflow: TextOverflow.ellipsis,
),
thank You Roque
Use layout Flexible/Container with text overflow:
Flexible(
child: Container(
child: Text(
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13.0,),
),
),
),
Actually, overflow: TextOverflow.ellipsis should work.
My guess is Text widget container making the Text widget shorter
Try wrapping Text widget in Container with maximum width
Container(
width: double.infinity,
child: Text(
'reaaaaaly long text, like reaaaaaaaaaaaaaly long',
overflow: TextOverflow.ellipsis,
),
You can use text property Overflow.elipsis.
ListTile(
shape: RoundedRectangleBorder(
minLeadingWidth: 0,
title: Text(
"Hello Overflow",
style: const TextStyle(
fontFamily: 'Open Sans',
fontSize: 15,
color: Color(0xff23233c),
letterSpacing: -0.44999999999999996,
fontWeight: FontWeight.w500,
),
softWrap: true,
overflow: TextOverflow.ellipsis,
),
)

fittedbox with maximum two lines in flutter

Container(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 60),
child: Text(
// subCategoryName,
"This is a very Long Text takes more space",
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.fade,
style: Theme.of(context)
.textTheme
.headline3
.copyWith(color: Colors.white, fontSize: 32),
),
),
),
Look this Picture
I need this line to be a maximum of two lines and shrink the size like a FittedBox (with BoxFit.fitWidth) if the text gets even longer
When I used the FittedBox it looking like this. But I need to take it up to 2 lines if needed.. Any solution is appreciated
Got it working by the reply of Sam Chan.
I used the AutoSizeText Package
If you don't want to add an pakage, here is workaround. You can check the length of the text and based on that you can handle it.
// declare a widget
Widget titleTextWidget = Text(
title,
style: TextStyle(
fontWeight: FontWeight.w600,
),
maxLines: 2,
textAlign: TextAlign.center,
);
// use condition to render it.
title.length > 45
? FittedBox(
child: titleTextWidget,
)
: titleTextWidget,

Scaling fonts with different screensizes

I am trying to scale my fonts so that they look the same on different screen sizes, large or small. I have the code below, which is linked to an underlying theme (flutter standard theme). I have tried manually changing the fontsize but this does not help since it looks different on all screen sizes.
Is there a recommended way to auto-scale fontsize depending on screen size?
Expanded(
child: Column(
children: <Widget>[
Padding(padding: EdgeInsets.all(MediaQuery.of(context).size.height/50)),
Text("We're finding your pizza!",
textAlign: TextAlign.center,
style: theme.textTheme.title.copyWith(fontSize: 26),
),
Padding(padding: EdgeInsets.all(MediaQuery.of(context).size.height/40)),
Text(
"We'll notify you when we've found one.",
textAlign: TextAlign.center,
style: theme.textTheme.title),
Padding(padding: EdgeInsets.all(MediaQuery.of(context).size.height/40)),
Text(
"Estimated wait time:",
textAlign: TextAlign.center,
style: theme.textTheme.title),
Padding(padding: EdgeInsets.all(MediaQuery.of(context).size.height/80)),
Text(
"< 1 minute.",
textAlign: TextAlign.center,
style: theme.textTheme.title,
)],
),
),
You can try auto_size_text
Installing
add this to your pubspec.yaml
auto_size_text: ^2.1.0
Usage
AutoSizeText(
'Your auto size text',
style: TextStyle(fontSize: 20),//minimum font size
maxLines: 2,//if needed
)