Repository navigation
ListTile Crashes When Width Is Reduced with Leading or Trailing Widgets #159380
Copy link
Copy link
Closed
Closed
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkfound in release: 3.24Found to occur in 3.24Found to occur in 3.24found in release: 3.27Found to occur in 3.27Found to occur in 3.27frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
When using the ListTile widget in a Flutter application on macOS, the app crashes if the window width is reduced and the ListTile contains a leading or trailing widget. This issue is reproducible consistently and seems related to how the widget handles layout constraints during window resizing.
Steps to reproduce
- Create a Flutter app targeting macOS.
- Add a ListTile widget with either a leading or trailing widget.
- Run the app and gradually reduce the width of the window.
- Observe that the app crashes when the window reaches a certain narrow width.
Expected results
The ListTile should adapt gracefully to changing window sizes without crashing, regardless of whether leading or trailing widgets are present.
Actual results
The application crashes as the window width decreases when a ListTile contains leading or trailing widgets. The crash appears to be related to layout constraints.
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:portfolio/providers.dart';
class Homepage extends ConsumerWidget {
const Homepage({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final portfolio = ref.watch(portfolioProvider);
return ListView.builder(
shrinkWrap: true,
itemCount: portfolio.length,
itemBuilder: (context, index) {
final stock = portfolio[index];
return ListTile(
title: Text(
stock.name,
overflow: TextOverflow.ellipsis,
),
subtitle: Text(
"Qty: ${stock.quantity}",
overflow: TextOverflow.ellipsis,
),
trailing: Text("Price: ${stock.price}"),
);
},
);
}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
_AssertionError._doThrowNew (/Users/ates/development/flutter/bin/cache/pkg/sky_engine/lib/_internal/vm/lib/errors_patch.dart:50)
_AssertionError._throwNew (/Users/ates/development/flutter/bin/cache/pkg/sky_engine/lib/_internal/vm/lib/errors_patch.dart:40)
_RenderListTile._computeSizes (/Users/ates/development/flutter/packages/flutter/lib/src/material/list_tile.dart:1356)
_RenderListTile.performLayout (/Users/ates/development/flutter/packages/flutter/lib/src/material/list_tile.dart:1459)
RenderObject.layout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/object.dart:2608)
RenderPadding.performLayout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/shifted_box.dart:234)
RenderObject.layout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/object.dart:2608)
RenderPadding.performLayout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/shifted_box.dart:234)
RenderObject.layout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/object.dart:2608)
RenderProxyBoxMixin.performLayout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:111)
RenderObject.layout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/object.dart:2608)
RenderProxyBoxMixin.performLayout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:111)
RenderObject.layout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/object.dart:2608)
RenderProxyBoxMixin.performLayout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:111)
RenderObject.layout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/object.dart:2608)
RenderProxyBoxMixin.performLayout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:111)
RenderObject.layout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/object.dart:2608)
RenderProxyBoxMixin.performLayout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:111)
RenderObject.layout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/object.dart:2608)
RenderProxyBoxMixin.performLayout (/Users/ates/development/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:111)
Flutter Doctor output
Doctor output
[Paste your output here]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkfound in release: 3.24Found to occur in 3.24Found to occur in 3.24found in release: 3.27Found to occur in 3.27Found to occur in 3.27frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Type
Projects
- StatusShow more project fieldsDone (PR merged)
Activity
darshankawar commentedon Nov 25, 2024
@atillayurtseven
The code sample you provided contains third party implementation. Does the reported behavior occur without using those packages code ? If so, please provide us updated code sample along with
flutter doctor -v.https://stackoverflow.com/help/minimal-reproducible-example
atillayurtseven commentedon Nov 25, 2024
Hi @darshankawar
Here's the cleaner code
And
flutter doctor -voutput:darshankawar commentedon Nov 26, 2024
Thanks for the update @atillayurtseven
The error log mentions / suggests why it could be occuring with a hint on how to fix it.
Try to use
SizedBoxwidget and follow the link mentioned of the example to see if it helps in your case or not.atillayurtseven commentedon Nov 27, 2024
Wrapping with SizedBox did not help
darshankawar commentedon Nov 27, 2024
Thanks for checking. As the error log points to https://api.flutter.dev/flutter/material/ListTile-class.html#material.ListTile.4 which I tried and doesn't throw the said error. Please try to see its implementation and check if it helps in your case or not.
atillayurtseven commentedon Nov 27, 2024
I have tried the ListTile.4 code in my Mac app and same problem occurs.
Please find the full code and the
flutter doctor -voutput below.flutter doctor -voutputdarshankawar commentedon Nov 28, 2024
In above code, if you update as below, then the said error doesn't occur:
20 remaining items
Update error message for when leading/trailing width exceeds `ListTil…
Update error message for when leading/trailing width exceeds `ListTil…
github-actions commentedon Jan 28, 2025
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.