-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Refactor FAB (Remove RawMaterialButton)
#99753
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
|
Gold has detected about 4 new digest(s) on patchset 1. |
|
Gold has detected about 6 new digest(s) on patchset 2. |
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. Changes reported for pull request #99753 at sha 016dc101e7edb794639ac3818896b2951f6e9866 |
Piinks
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.
Wow! Thank you for doing this. It looks like the golden file images show the color is slightly different, but I don't know if that is expected in the new design.
I am deferring to @HansMuller on the general design since he wrote the new Button/ButtonStyle universe. If this looks ok in keeping with the new paradigm I can give it a more thorough review.
I am wondering first if we are going to maintain all of the numerated properties on FAB, or deprecate and redirect them to be fashioned in a ButtonStyle. I think either approach has pros and cons, and this current one seems clean and minimally disruptive.
FAB already has its own FABTheme, so all of that churn would extend there as well. That being said I like this approach
HansMuller
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.
I agree with Kate that just changing FAB's implementation, without adopting the ButtonStyle API here and in the FAB theme, is the prudent change to make. I think that applies to ToggleButtons as well, per Kate's feedback.
Supporting a ButtonStyle style parameter for FAB and ToggleButtons is a separate decision. If we choose to do that; it would be separate PR as well as a plan for migration, etc.
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.
Maybe leave mixing in Diagnosticable for a separate PR that does so for ButtonStyleButton and then adds whatever debugFillProperties overrides are needed for the other ButtonStyleButtons.
|
Gold has detected about 6 new digest(s) on patchset 3. |
Piinks
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.
Hey @TahaTesser what is the state of this PR? It looks like there are some failing tests.
I am concerned the subtle color change will cause a lot of internal tests to fail.
Hey @Piinks
These golden changes are due to ButtonStyleButton setting #99493 also has the same changes related highlight color. |
|
Awesome! Thanks for the update, I was just checking that I was not neglecting this if it needed another review. :) |
|
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
14e0af1 to
b5bd455
Compare
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. Changes reported for pull request #99753 at sha b5bd45514c754c0dc5ad5f6caa2272f8987cb9e0 |
|
@Piinks This is ready to review |
Piinks
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.
This looks great! Just some style nits. I am checking with customer tests.
packages/flutter/test/material/floating_action_button_theme_test.dart
Outdated
Show resolved
Hide resolved
examples/api/test/material/floating_action_button/floating_action_button.0_test.dart
Outdated
Show resolved
Hide resolved
packages/flutter/test/material/floating_action_button_theme_test.dart
Outdated
Show resolved
Hide resolved
packages/flutter/test/material/floating_action_button_theme_test.dart
Outdated
Show resolved
Hide resolved
|
There are indeed some customers to migrate, working on that now. I'll update to land once complete. :) |
|
Update: still working with customers. There are some changes here that cause the color of the button to fail contrast guidelines when pressed. That may be related to the highlight color change you mentioned above, still tracking it down. |
|
Not forgotten. :) Just back from time off, following up on customer migrations. I'll report back tomorrow. |
|
@TahaTesser can you update this branch with the latest from master? I am having trouble using our tools to sync this with the internal copy for testing. Thanks! |
a6ff21f to
abf17f9
Compare
|
Thanks for updating! This is still going to take a minute to fix all of the affected customers, we're making progress though! |
abf17f9 to
b17e29a
Compare
|
@Piinks |
|
Thanks for the update! This is now at the front of my customer migration list. |
|
Welcome back from vacation again. :) This is under active migration with customers. |
|
@Piinks |
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.
| shape: MaterialStateProperty.all<OutlinedBorder?>(shape as OutlinedBorder), | |
| shape: MaterialStateProperty.all<OutlinedBorder?>(shape as OutlinedBorder), |
This is causing issues for customers that have
FloatingActionButton(
shape: Border(),
...
)
Is there a way that this can still be supported? Or is it a breaking change?
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.
It can still be supported by wrapping ElevatedButton with DecoratedBox BUT this can be done by the customer too, floatingActionButton: takes any widget so FAB can be wrapped in a DecoratedBox.
The reason when Border() provide to the shape parameter currently works is because material.dart checks if "shape" is a ShapeBorder otherwise based on material type, directly draw the border with custom paint hence there is no issue with this in the current design.
flutter/packages/flutter/lib/src/material/material.dart
Lines 908 to 916 in 75ee440
| class _ShapeBorderPainter extends CustomPainter { | |
| _ShapeBorderPainter(this.border, this.textDirection); | |
| final ShapeBorder border; | |
| final TextDirection? textDirection; | |
| @override | |
| void paint(Canvas canvas, Size size) { | |
| border.paint(canvas, Offset.zero & size, textDirection: textDirection); | |
| } |
but there is no existing test where the border is provided to shape in the test class and looks a little bit off to me when the border is provided to shape parameter.
If you still want this, I can wrap ElevatedButton with DecoratedBox along with a couple of tests to make sure this behavior works as expected.
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.
If you still want this, I can wrap ElevatedButton with DecoratedBox along with a couple of tests to make sure this behavior works as expected.
There are a surprising number of cases with Border, if we can still support it, it would be definitely be easier. Do you want to try it and see what it would look like?
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.
I just added the code.
decoration: ShapeDecoration(shape: shape), is responsible for rendering the border and we're defaulting to a rectangular shape to match current behavior when a border is provided.
shape: MaterialStateProperty.all<OutlinedBorder?>(shape is! OutlinedBorder
? const RoundedRectangleBorder()
: shape as OutlinedBorder?,
),b17e29a to
c0a3764
Compare
|
Still catching up from having covid, thanks for your patience. For this, there is one more customer test file that I need to migrate, and then this should be ready. |
|
@Piinks |
|
Closing this PR for now. Will come to this with a clean PR in the future. |

fixes #99086
Description
This PR replaced
RawMaterialButtonwithElevatedButton(as it is obsolete and soon to be deprecated)There are golden changes due to highlight color not being translated to ElevatedButton (
ButtonStyleButtonsets highlight color to be transparent).Highlight color golden changes preview (when FAB Is pressed)
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.