Unverified Commit e93297b9 authored by Alex Sandri's avatar Alex Sandri Committed by GitHub

fix overflow error in `CupertinoListTile` (#113010)

parent 300181b3
...@@ -283,6 +283,7 @@ class _CupertinoListTileState extends State<CupertinoListTile> { ...@@ -283,6 +283,7 @@ class _CupertinoListTileState extends State<CupertinoListTile> {
final Widget title = DefaultTextStyle( final Widget title = DefaultTextStyle(
style: titleTextStyle, style: titleTextStyle,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis,
child: widget.title, child: widget.title,
); );
...@@ -303,6 +304,7 @@ class _CupertinoListTileState extends State<CupertinoListTile> { ...@@ -303,6 +304,7 @@ class _CupertinoListTileState extends State<CupertinoListTile> {
subtitle = DefaultTextStyle( subtitle = DefaultTextStyle(
style: subtitleTextStyle, style: subtitleTextStyle,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis,
child: widget.subtitle!, child: widget.subtitle!,
); );
} }
...@@ -353,18 +355,19 @@ class _CupertinoListTileState extends State<CupertinoListTile> { ...@@ -353,18 +355,19 @@ class _CupertinoListTileState extends State<CupertinoListTile> {
SizedBox(width: widget.leadingToTitle), SizedBox(width: widget.leadingToTitle),
] else ] else
SizedBox(height: widget.leadingSize), SizedBox(height: widget.leadingSize),
Column( Expanded(
mainAxisAlignment: MainAxisAlignment.spaceBetween, child: Column(
crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ crossAxisAlignment: CrossAxisAlignment.start,
title, children: <Widget>[
if (subtitle != null) ...<Widget>[ title,
const SizedBox(height: _kNotchedTitleToSubtitle), if (subtitle != null) ...<Widget>[
subtitle, const SizedBox(height: _kNotchedTitleToSubtitle),
subtitle,
],
], ],
], ),
), ),
const Spacer(),
if (additionalInfo != null) ...<Widget>[ if (additionalInfo != null) ...<Widget>[
additionalInfo, additionalInfo,
if (widget.trailing != null) if (widget.trailing != null)
......
...@@ -519,4 +519,33 @@ void main() { ...@@ -519,4 +519,33 @@ void main() {
await tester.pumpAndSettle(const Duration(seconds: 5)); await tester.pumpAndSettle(const Duration(seconds: 5));
expect(tester.takeException(), null); expect(tester.takeException(), null);
}); });
testWidgets('title does not overflow', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: CupertinoPageScaffold(
child: CupertinoListTile(
title: Text('CupertinoListTile' * 10),
),
),
),
);
expect(tester.takeException(), null);
});
testWidgets('subtitle does not overflow', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: CupertinoPageScaffold(
child: CupertinoListTile(
title: const Text(''),
subtitle: Text('CupertinoListTile' * 10),
),
),
),
);
expect(tester.takeException(), null);
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment