-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Make sure that a Banner doesn't crash in 0x0 environment #180254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
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 regression test to ensure the Banner widget does not crash when rendered in a zero-sized area. The test case is well-written and covers the intended scenario.
While reviewing this change, I also looked at the implementation of the Banner widget in packages/flutter/lib/src/widgets/banner.dart and found a couple of issues that could be addressed in a follow-up change:
-
Painter Lifecycle: In
_BannerState, theBannerPainteris recreated and disposed on everybuildcall. This is inefficient and can lead to a race condition where a painter is used after being disposed. A safer approach would be to delay the disposal of the old painter until the next frame. -
Incomplete
shouldRepaint: TheBannerPainter.shouldRepaintmethod does not check for changes intextDirection,layoutDirection, orshadow. This can lead to incorrect rendering if these properties change.
These are separate issues from the test being added, but are relevant to the overall quality of the Banner widget.
dkwingsmt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checklist:
- The test is in the correct file
- The test name goes “does not crash at zero area”
- The target widget is wrapped by
Center(or is fullscreen) - The target widget does not have an overlay, or the overlay is tested
- The target widget is expected to have a size of exactly
Size.zero
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
|
@ahmedsameha1 Can you resolve the merge conflict? (kinda hard to do on web) |
|
autosubmit label was removed for flutter/flutter/180254, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR. |
Manual roll requested by tarrinneal@google.com flutter/flutter@793b0b8...b45a73b 2026-01-13 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#180900) 2026-01-13 engine-flutter-autoroll@skia.org Roll Dart SDK from 34318de9874b to ebaf52c13799 (1 revision) (flutter/flutter#180870) 2026-01-13 ahmedsameha1@gmail.com Make sure that an ErrorWidget doesn't crash in 0x0 environment (flutter/flutter#180830) 2026-01-13 ahmedsameha1@gmail.com Make sure that a Banner doesn't crash in 0x0 environment (flutter/flutter#180254) 2026-01-13 30870216+gaaclarke@users.noreply.github.com Adds metal background to engine dart tests (flutter/flutter#180700) 2026-01-13 huy@nevercode.io Add TabBar API example for scroll notification integration (flutter/flutter#180728) 2026-01-13 engine-flutter-autoroll@skia.org Roll Skia from 714d0af2eda7 to 8f3134206e8d (1 revision) (flutter/flutter#180874) 2026-01-13 97480502+b-luk@users.noreply.github.com Add build-time checks for ImpellerC's SkSL compiler (flutter/flutter#180861) 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 stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
) This is my attempt to handle flutter#6537 for the Banner widget. Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
This is my attempt to handle #6537 for the Banner widget.