-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Expose toggle to textfield's opacity animation. #122474
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
Expose toggle to textfield's opacity animation. #122474
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
2d1dc0a to
6d78581
Compare
|
Missing documentation for the new params: |
…inn/flutter into disable-textfield-opacity-animation
|
@jmagman I've updated the docs. Not sure why that macro didn't work, but it's building now. |
|
The macro wasn't working because there wasn't a definition for it. If you'd like to use the handy macro feature in the docs, you can add a /// {@template flutter.widgets.editableText.cursorRadius}
/// How rounded the corners of the cursor should be.
///
/// By default, the cursor has no radius.
/// {@endtemplate}
final Radius? cursorRadius;
/// Whether the cursor will animate from fully transparent to fully opaque
/// during each cursor blink.
///
/// By default, the cursor opacity will animate on iOS platforms and will not
/// animate on Android platforms.
final bool cursorOpacityAnimates;That |
|
@gnprice Oh nice, thanks for the tip! |
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.
I'm on board with this. Since cursorOpacityAnimates already exists on EditableText, I see no reason why we shouldn't expose it on TextField and CupertinoTextField.
Can you add tests for this? I think you can simply add one for each of TextField and CupertinoTextField, and verify that underlying EditableText has the correct cursorOpacityAnimates value.
Also, have you verified that turning this off does indeed fix the CPU performance issue? I see you commented on the issue with some hard numbers, were those taken from disabling and enabling this on EditableText?
| /// during each cursor blink. | ||
| /// | ||
| /// By default, the cursor opacity will animate on iOS platforms and will not | ||
| /// animate on Android platforms. |
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.
Can you use a macro/template here instead of duplicating this? I see some discussion above about a macro not working before but let me know if you can't get it.
…inn/flutter into disable-textfield-opacity-animation
|
@justinmc I've added the macro for the docs and added tests you suggested for material and cupertino. I have also manually verified that the toggle overrides the default platform value correctly on a linux computer and mac.
Correct, I tested this by disabling/enabling the parameter in the text field examples. Nothing but the text field is present in the test app. I have checked the CPU usage on multiple platforms (linux, macOS, iOS, windows) on physical devices, not emulators and in release mode. Each platform shows the same trend -- with the animation enabled I see a constant 10-16% cpu usage and with it disabled I see 0% cpu usage. On desktop platforms I measured CPU using htop and the systems system monitor program. For iOS I used xCode's profiler/monitor thing. |
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 👍. Thank you for the fixes!
|
@justinmc Sweet, thanks for the review! What exactly is the process for getting this merged? |
werainkhatri
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.
|
Sorry @Blquinn, the process was just to find a secondary reviewer, which @werainkhatri has been nice enough to provide. Now this will merge automatically when the tree is green. |
|
Awesome; no problem at all. Thank you both! |
|
The tree is green, but the "Google testing" check for this PR seems to have gotten stuck: One workaround is to update the PR so the check gets restarted. I'm not sure if there are other workarounds a Googler could apply. |
* cbdee52 Roll Flutter Engine from 59acb5362098 to 12c822327825 (3 revisions) (flutter/flutter#123330) * 897e3db Inject the gstatic CanvasKit CDN URL by default in `flutter build web` (flutter/flutter#122772) * 5a36bdd Stop serving Observatory by default (flutter/flutter#122419) * b212e7b implement Iterator and Comparable instead of extending them (flutter/flutter#123282) * af6029c c0fbe5a53 Roll Dart SDK from 9256fffbd5af to e8e045620234 (1 revision) (flutter/engine#40561) (flutter/flutter#123336) * 9dec4fb FIX: NavigationDrawer hover/focus/pressed does not use indicatorShape (flutter/flutter#123325) * 4907464 20ab040cd Roll Skia from ce5ff5cc03ce to c42320d53714 (2 revisions) (flutter/engine#40565) (flutter/flutter#123340) * 28d40a4 Roll Packages from 75491e9 to 0826798 (5 revisions) (flutter/flutter#123342) * 674ff15 [macOS] Add platform_channel sample/test (flutter/flutter#123141) * 7b7af9f roll packages (flutter/flutter#123339) * 3179875 replace some ._() constructors with class modifiers (flutter/flutter#122765) * 7f41ab2 Fix (insert|move|remove)RenderObjectChild methods in base class (flutter/flutter#123276) * fccca49 Refactor buildOverscrollIndicator (flutter/flutter#123246) * 11bbce1 6b0933e74 [web] Add `dart:js_interop` to `_embedder.yaml`. (flutter/engine#40545) (flutter/flutter#123347) * 716d252 Remove prefer_const_constructors ignores (flutter/flutter#123284) * 100cf21 Prefer enum over class. (flutter/flutter#123312) * 5ef9b84 Expose toggle to textfield's opacity animation. (flutter/flutter#122474) * d79f3aa Roll Flutter Engine from 6b0933e74965 to bdce896fb64f (2 revisions) (flutter/flutter#123351)
) * cbdee52 Roll Flutter Engine from 59acb5362098 to 12c822327825 (3 revisions) (flutter/flutter#123330) * 897e3db Inject the gstatic CanvasKit CDN URL by default in `flutter build web` (flutter/flutter#122772) * 5a36bdd Stop serving Observatory by default (flutter/flutter#122419) * b212e7b implement Iterator and Comparable instead of extending them (flutter/flutter#123282) * af6029c c0fbe5a53 Roll Dart SDK from 9256fffbd5af to e8e045620234 (1 revision) (flutter/engine#40561) (flutter/flutter#123336) * 9dec4fb FIX: NavigationDrawer hover/focus/pressed does not use indicatorShape (flutter/flutter#123325) * 4907464 20ab040cd Roll Skia from ce5ff5cc03ce to c42320d53714 (2 revisions) (flutter/engine#40565) (flutter/flutter#123340) * 28d40a4 Roll Packages from 75491e9 to 0826798 (5 revisions) (flutter/flutter#123342) * 674ff15 [macOS] Add platform_channel sample/test (flutter/flutter#123141) * 7b7af9f roll packages (flutter/flutter#123339) * 3179875 replace some ._() constructors with class modifiers (flutter/flutter#122765) * 7f41ab2 Fix (insert|move|remove)RenderObjectChild methods in base class (flutter/flutter#123276) * fccca49 Refactor buildOverscrollIndicator (flutter/flutter#123246) * 11bbce1 6b0933e74 [web] Add `dart:js_interop` to `_embedder.yaml`. (flutter/engine#40545) (flutter/flutter#123347) * 716d252 Remove prefer_const_constructors ignores (flutter/flutter#123284) * 100cf21 Prefer enum over class. (flutter/flutter#123312) * 5ef9b84 Expose toggle to textfield's opacity animation. (flutter/flutter#122474) * d79f3aa Roll Flutter Engine from 6b0933e74965 to bdce896fb64f (2 revisions) (flutter/flutter#123351)

This exposes the toggle to cupertino/material textfield's opacity animation so that users can disable the cursor opacity animation if they choose to.
Sort of fixes #59327
List which issues are fixed by this PR. You must list at least one issue.
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.