Reputation:
Here is a code:
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home: Home()));
}
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
width: 200,
color: Colors.green[200],
child: Text(
'https://someurl.com/4792479008289298462374623746723457',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
);
}
}
the result is not exactly what I expected:
but I need something like this:
softWrap
doesn't help in this case
Upvotes: 3
Views: 1805
Reputation: 14053
Following the Github issue: Text overflow with ellipsis is weird and ugly by design
Here is a quick fix for it:
- The
TextOverflow.ellipsis
uses a regex pattern\u2026
, you can apply a regex pattern[\u{200B}
] on theText data
Code :
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
width: 200,
color: Colors.green[200],
child: Text(
'https://someurl.com/479247900828929846'.replaceAll("", "\u{200B}"),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
);
}
}
OUTPUT:
- Use the flutter package which gives you the ability to do this Assorted Layout Widgets
Upvotes: 15