Skip to content

Make sure that an ImageIcon doesn't crash in 0x0 environment#181099

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
ahmedsameha1:handle#6537-ImageIcon
Jan 27, 2026
Merged

Make sure that an ImageIcon doesn't crash in 0x0 environment#181099
auto-submit[bot] merged 2 commits into
flutter:masterfrom
ahmedsameha1:handle#6537-ImageIcon

Conversation

@ahmedsameha1

Copy link
Copy Markdown
Contributor

This is my attempt to handle #6537 for the ImageIcon widget.

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Jan 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a test to ensure that ImageIcon does not crash when rendered in a zero-sized area. However, the added test uses a null image, which doesn't cover the code path that was causing the crash. My review includes a critical comment to correct the test to use a non-null image, which will properly validate the fix for the issue.

Comment on lines +103 to +106
const Directionality(
textDirection: TextDirection.ltr,
child: Center(child: SizedBox.shrink(child: ImageIcon(null))),
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The test 'ImageIcon does not crash at zero area' is intended to verify that ImageIcon doesn't crash in a 0x0 environment, as described in issue #6537. However, the test uses ImageIcon(null).

When image is null, ImageIcon returns a SizedBox and doesn't go through the code path that involves rendering an image with a color, which is what causes the crash.

To properly test the fix, you should use a non-null ImageProvider. The image variable defined in setUpAll can be used for this purpose. Also, since image is not a constant, the const keyword should be removed from Directionality.

Suggested change
const Directionality(
textDirection: TextDirection.ltr,
child: Center(child: SizedBox.shrink(child: ImageIcon(null))),
),
Directionality(
textDirection: TextDirection.ltr,
child: Center(child: SizedBox.shrink(child: ImageIcon(image))),
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, can we test with non-null image?

await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Center(child: SizedBox.shrink(child: ImageIcon(image))),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are leaks, should image be disposed or similar?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we need to add a imageCache.clear(); at the end.

@ahmedsameha1 ahmedsameha1 force-pushed the handle#6537-ImageIcon branch from 862837c to f8fb66b Compare January 22, 2026 18:13
@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 27, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Jan 27, 2026
Merged via the queue into flutter:master with commit 1c0ccb5 Jan 27, 2026
71 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 27, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 28, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 28, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 28, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 28, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 29, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jan 29, 2026
Roll Flutter from dfd92b773219 to da72d5936d69 (39 revisions)

flutter/flutter@dfd92b7...da72d59

2026-01-29 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[ Tool / Engine ] Cleanup x86 references (#181152)" (flutter/flutter#181643)
2026-01-29 engine-flutter-autoroll@skia.org Roll Skia from 174db42b7300 to 89df65f8324c (2 revisions) (flutter/flutter#181636)
2026-01-29 59215665+davidhicks980@users.noreply.github.com [material/menu_anchor.dart] Add animations to MenuAnchor. (flutter/flutter#176494)
2026-01-28 engine-flutter-autoroll@skia.org Roll Skia from 8e09f8a82251 to 174db42b7300 (6 revisions) (flutter/flutter#181627)
2026-01-28 31859944+LongCatIsLooong@users.noreply.github.com Send statusBarTouch events via dedicated messages (flutter/flutter#179643)
2026-01-28 git@reb0.org test: Improve DropdownMenuFormField tests (flutter/flutter#181369)
2026-01-28 evanwall@buffalo.edu Account for vec3 padding in Metal (flutter/flutter#181563)
2026-01-28 bkonyi@google.com [ Tool / Engine ] Cleanup x86 references (flutter/flutter#181152)
2026-01-28 ybz975218925@gmail.com Fix the issue on macOS where, after a hot restart with multiple windows, unresponsive windows are left behind. (flutter/flutter#180287)
2026-01-28 engine-flutter-autoroll@skia.org Roll Skia from 675444e94bc9 to 8e09f8a82251 (7 revisions) (flutter/flutter#181606)
2026-01-28 engine-flutter-autoroll@skia.org Roll Packages from e37af11 to 1cb2148 (5 revisions) (flutter/flutter#181608)
2026-01-28 codefu@google.com fix: swap app and engine version in vk::ApplicationInfo (flutter/flutter#181432)
2026-01-28 30870216+gaaclarke@users.noreply.github.com Adds impeller backend to skia gold client (flutter/flutter#181503)
2026-01-28 mdebbar@google.com Remove chrome_and_driver dependency where it's not needed (flutter/flutter#178174)
2026-01-28 codefu@google.com chore: Windows_mokey basic_material_app_win__compile !bringup (flutter/flutter#180985)
2026-01-28 116356835+AbdeMohlbi@users.noreply.github.com Fix generating both `settings.gradle` and `settings.gradle.kts` for plugins (flutter/flutter#181592)
2026-01-28 engine-flutter-autoroll@skia.org Roll Skia from 6614f89de521 to 675444e94bc9 (3 revisions) (flutter/flutter#181587)
2026-01-28 104349824+huycozy@users.noreply.github.com Fix `todayBorder` todayBorder color is incorrectly overridden by `todayForegroundColor` in CalendarDatePicker (flutter/flutter#178792)
2026-01-28 engine-flutter-autoroll@skia.org Roll Skia from 8f1695a4b328 to 6614f89de521 (2 revisions) (flutter/flutter#181583)
2026-01-28 34465683+rkishan516@users.noreply.github.com feat: add RoundedSuperellipseInputBorder (flutter/flutter#177220)
2026-01-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 38e351498549 to f10dcbfca98f (2 revisions) (flutter/flutter#181582)
2026-01-28 engine-flutter-autoroll@skia.org Roll Skia from f424d58e37a3 to 8f1695a4b328 (6 revisions) (flutter/flutter#181577)
2026-01-28 116356835+AbdeMohlbi@users.noreply.github.com Remove unused code paths  in `PlatformViewsController.java` (flutter/flutter#181393)
2026-01-28 34465683+rkishan516@users.noreply.github.com feat: add onEnd to AnimatedCrossFade (flutter/flutter#181455)
2026-01-28 1961493+harryterkelsen@users.noreply.github.com Don't pass bounds to saveLayer call when painting ImageFilter (flutter/flutter#181353)
2026-01-28 luanpotter27@gmail.com test: Clarify failure messages on gestures/debug_test.dart (flutter/flutter#181109)
2026-01-27 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from akraNGn2lw4T1msgZ... to adhoq9ouVRh0xzkm3... (flutter/flutter#181571)
2026-01-27 engine-flutter-autoroll@skia.org Roll Dart SDK from 4c7cb0a1d07d to 38e351498549 (4 revisions) (flutter/flutter#181570)
2026-01-27 ahmedsameha1@gmail.com Make sure that an AnimatedPadding doesn't crash in 0x0 environment (flutter/flutter#181235)
2026-01-27 ahmedsameha1@gmail.com Make sure that an ImageFiltered doesn't crash at 0x0 environment (flutter/flutter#181067)
2026-01-27 magder@google.com Marks firebase_release_smoke_test to be unflaky (flutter/flutter#181308)
2026-01-27 kazbek.sultanov.doc@gmail.com Fix remove material import box decoration test (flutter/flutter#181253)
2026-01-27 engine-flutter-autoroll@skia.org Roll Skia from c2754838b077 to f424d58e37a3 (8 revisions) (flutter/flutter#181564)
2026-01-27 ahmedsameha1@gmail.com Make sure that an AnimatedAlign doesn't crash in 0x0 environment (flutter/flutter#181361)
2026-01-27 ahmedsameha1@gmail.com Make sure that an ImageIcon doesn't crash in 0x0 environment (flutter/flutter#181099)
2026-01-27 ahmedsameha1@gmail.com Make sure that an AnimatedContainer doesn't crash in 0x0 environment (flutter/flutter#181198)
2026-01-27 ahmedsameha1@gmail.com Make sure that an AnimatedRotation doesn't crash in 0x0 environment (flutter/flutter#181486)
2026-01-27 ahmedsameha1@gmail.com Make sure that an AnimatedPositionedDirectional doesn't crash in 0x0 … (flutter/flutter#181451)
2026-01-27 jacksongardner@google.com Merge changelog for 3.38.8. (flutter/flutter#181558)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

...
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Feb 10, 2026
…#181099)

This is my attempt to handle
flutter#6537 for the ImageIcon widget.

Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…r#10923)

Roll Flutter from dfd92b773219 to da72d5936d69 (39 revisions)

flutter/flutter@dfd92b7...da72d59

2026-01-29 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[ Tool / Engine ] Cleanup x86 references (#181152)" (flutter/flutter#181643)
2026-01-29 engine-flutter-autoroll@skia.org Roll Skia from 174db42b7300 to 89df65f8324c (2 revisions) (flutter/flutter#181636)
2026-01-29 59215665+davidhicks980@users.noreply.github.com [material/menu_anchor.dart] Add animations to MenuAnchor. (flutter/flutter#176494)
2026-01-28 engine-flutter-autoroll@skia.org Roll Skia from 8e09f8a82251 to 174db42b7300 (6 revisions) (flutter/flutter#181627)
2026-01-28 31859944+LongCatIsLooong@users.noreply.github.com Send statusBarTouch events via dedicated messages (flutter/flutter#179643)
2026-01-28 git@reb0.org test: Improve DropdownMenuFormField tests (flutter/flutter#181369)
2026-01-28 evanwall@buffalo.edu Account for vec3 padding in Metal (flutter/flutter#181563)
2026-01-28 bkonyi@google.com [ Tool / Engine ] Cleanup x86 references (flutter/flutter#181152)
2026-01-28 ybz975218925@gmail.com Fix the issue on macOS where, after a hot restart with multiple windows, unresponsive windows are left behind. (flutter/flutter#180287)
2026-01-28 engine-flutter-autoroll@skia.org Roll Skia from 675444e94bc9 to 8e09f8a82251 (7 revisions) (flutter/flutter#181606)
2026-01-28 engine-flutter-autoroll@skia.org Roll Packages from e37af11 to 1cb2148 (5 revisions) (flutter/flutter#181608)
2026-01-28 codefu@google.com fix: swap app and engine version in vk::ApplicationInfo (flutter/flutter#181432)
2026-01-28 30870216+gaaclarke@users.noreply.github.com Adds impeller backend to skia gold client (flutter/flutter#181503)
2026-01-28 mdebbar@google.com Remove chrome_and_driver dependency where it's not needed (flutter/flutter#178174)
2026-01-28 codefu@google.com chore: Windows_mokey basic_material_app_win__compile !bringup (flutter/flutter#180985)
2026-01-28 116356835+AbdeMohlbi@users.noreply.github.com Fix generating both `settings.gradle` and `settings.gradle.kts` for plugins (flutter/flutter#181592)
2026-01-28 engine-flutter-autoroll@skia.org Roll Skia from 6614f89de521 to 675444e94bc9 (3 revisions) (flutter/flutter#181587)
2026-01-28 104349824+huycozy@users.noreply.github.com Fix `todayBorder` todayBorder color is incorrectly overridden by `todayForegroundColor` in CalendarDatePicker (flutter/flutter#178792)
2026-01-28 engine-flutter-autoroll@skia.org Roll Skia from 8f1695a4b328 to 6614f89de521 (2 revisions) (flutter/flutter#181583)
2026-01-28 34465683+rkishan516@users.noreply.github.com feat: add RoundedSuperellipseInputBorder (flutter/flutter#177220)
2026-01-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 38e351498549 to f10dcbfca98f (2 revisions) (flutter/flutter#181582)
2026-01-28 engine-flutter-autoroll@skia.org Roll Skia from f424d58e37a3 to 8f1695a4b328 (6 revisions) (flutter/flutter#181577)
2026-01-28 116356835+AbdeMohlbi@users.noreply.github.com Remove unused code paths  in `PlatformViewsController.java` (flutter/flutter#181393)
2026-01-28 34465683+rkishan516@users.noreply.github.com feat: add onEnd to AnimatedCrossFade (flutter/flutter#181455)
2026-01-28 1961493+harryterkelsen@users.noreply.github.com Don't pass bounds to saveLayer call when painting ImageFilter (flutter/flutter#181353)
2026-01-28 luanpotter27@gmail.com test: Clarify failure messages on gestures/debug_test.dart (flutter/flutter#181109)
2026-01-27 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from akraNGn2lw4T1msgZ... to adhoq9ouVRh0xzkm3... (flutter/flutter#181571)
2026-01-27 engine-flutter-autoroll@skia.org Roll Dart SDK from 4c7cb0a1d07d to 38e351498549 (4 revisions) (flutter/flutter#181570)
2026-01-27 ahmedsameha1@gmail.com Make sure that an AnimatedPadding doesn't crash in 0x0 environment (flutter/flutter#181235)
2026-01-27 ahmedsameha1@gmail.com Make sure that an ImageFiltered doesn't crash at 0x0 environment (flutter/flutter#181067)
2026-01-27 magder@google.com Marks firebase_release_smoke_test to be unflaky (flutter/flutter#181308)
2026-01-27 kazbek.sultanov.doc@gmail.com Fix remove material import box decoration test (flutter/flutter#181253)
2026-01-27 engine-flutter-autoroll@skia.org Roll Skia from c2754838b077 to f424d58e37a3 (8 revisions) (flutter/flutter#181564)
2026-01-27 ahmedsameha1@gmail.com Make sure that an AnimatedAlign doesn't crash in 0x0 environment (flutter/flutter#181361)
2026-01-27 ahmedsameha1@gmail.com Make sure that an ImageIcon doesn't crash in 0x0 environment (flutter/flutter#181099)
2026-01-27 ahmedsameha1@gmail.com Make sure that an AnimatedContainer doesn't crash in 0x0 environment (flutter/flutter#181198)
2026-01-27 ahmedsameha1@gmail.com Make sure that an AnimatedRotation doesn't crash in 0x0 environment (flutter/flutter#181486)
2026-01-27 ahmedsameha1@gmail.com Make sure that an AnimatedPositionedDirectional doesn't crash in 0x0 … (flutter/flutter#181451)
2026-01-27 jacksongardner@google.com Merge changelog for 3.38.8. (flutter/flutter#181558)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants