Skip to content

Commit 7c797a0

Browse files
authored
fix: text overflow in CosmosTextButton (#267)
1 parent 394cc77 commit 7c797a0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/cosmos_ui_components/lib/components/cosmos_text_button.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class CosmosTextButton extends StatelessWidget {
1414
this.textStyle,
1515
this.iconTopSpacing,
1616
this.color,
17+
this.maxLines = 1,
18+
this.overflow = TextOverflow.ellipsis,
1719
}) : super(key: key);
1820

1921
static const defaultHeight = 50.0;
@@ -26,6 +28,8 @@ class CosmosTextButton extends StatelessWidget {
2628
final TextStyle? textStyle;
2729
final Color? color;
2830
final double? iconTopSpacing;
31+
final int maxLines;
32+
final TextOverflow overflow;
2933

3034
@override
3135
Widget build(BuildContext context) {
@@ -48,10 +52,9 @@ class CosmosTextButton extends StatelessWidget {
4852
],
4953
Text(
5054
text,
51-
style: textStyle ??
52-
CosmosTextTheme.elevatedButton.copyWith(
53-
color: color,
54-
),
55+
maxLines: maxLines,
56+
overflow: overflow,
57+
style: textStyle ?? CosmosTextTheme.elevatedButton.copyWith(color: color),
5558
),
5659
if (suffixIcon != null) ...[
5760
if (text.isNotEmpty) SizedBox(width: CosmosTheme.of(context).spacingS),
@@ -74,6 +77,8 @@ class CosmosTextButton extends StatelessWidget {
7477
..add(ColorProperty('color', color))
7578
..add(StringProperty('text', text))
7679
..add(DiagnosticsProperty<TextStyle?>('textStyle', textStyle))
77-
..add(DoubleProperty('height', height));
80+
..add(DoubleProperty('height', height))
81+
..add(IntProperty('maxLines', maxLines))
82+
..add(EnumProperty<TextOverflow>('overflow', overflow));
7883
}
7984
}

0 commit comments

Comments
 (0)