Skip to content

Commit 31bda5f

Browse files
committed
Show ellipsis when article description is too long to fit the space
1 parent fcf30ba commit 31bda5f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/ui/article_page.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,16 @@ class ArticlePage extends StatelessWidget {
106106
Expanded(
107107
child: Padding(
108108
padding: EdgeInsets.all(10.0),
109-
child: Text(
110-
article.description,
111-
style: TextStyle(fontSize: 18.0, color: Colors.black54),
112-
),
109+
child: new LayoutBuilder(
110+
builder: (BuildContext context, BoxConstraints constraints) {
111+
print(constraints);
112+
return new Text(
113+
article.description,
114+
overflow: TextOverflow.ellipsis,
115+
style: TextStyle(fontSize: 18.0, color: Colors.black54),
116+
maxLines: (constraints.maxHeight / 18.0).floor() - 1,
117+
);
118+
}),
113119
),
114120
),
115121
Row(

0 commit comments

Comments
 (0)