-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Add const to TextInputFormatter #114592
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
Add const to TextInputFormatter #114592
Conversation
It seems test failures are not related to the change I made so I decided to open this pull request |
Thanks for contributing. The change makes sense to me, but the test failures are related, "Linux analyze" is complaining there's missing documentation. Also this seems to be testable, could you add a test for that? |
@LongCatIsLooong
Thanks for your support! |
You should be able to find plenty of examples here: https://github.com/flutter/flutter/blob/master/packages/flutter/test/services/text_formatter_test.dart. The test failure is here: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8798526700594975537/+/u/Analyze/analyze/test_stdout. The new public constructor needs to be documented. |
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. 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. |
@LongCatIsLooong Could you give me a clear code example of tests? It would be so helpful. Thanks in advance. |
@@ -7,6 +7,13 @@ import 'package:flutter/services.dart'; | |||
import 'package:flutter_test/flutter_test.dart'; | |||
|
|||
void main() { | |||
test('test const constructor', () { | |||
const testValue1 = TextInputFormatter(); |
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.
TextInputFormatter is an abstract class and cannot be instantiated.
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.
@goderbauer
Thanks for your comment. Should I write tests for const constructors of subclasses instead?
For tests I think the ones you added were fine, just have to make sure you can add |
@LongCatIsLooong |
@@ -7,6 +7,19 @@ import 'package:flutter/services.dart'; | |||
import 'package:flutter_test/flutter_test.dart'; | |||
|
|||
void main() { | |||
test('test const constructor', () { | |||
const testValue1 = _SimpleTextInputFormatter(); |
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.
These don't have a const constructor or a constructor that takes 0 arguments. Could you create a concrete TextInputFormatter sub-class in the test file, with a const constructor?
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 for replying late. Is my understanding correct?
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 don't think you can declare inline classes in dart. You can try out the test by following this section from the wiki
(triage): @shogohida looks like the checks failed due to some infra issue. Could you merge in the latest master to kick the checks again? Thanks. |
* Allows pushing page based route as pageless route * update
* delete screenshot_test.dart * remove image dep * pub get
…lutter#115672) * a76ec9158 Roll Fuchsia Linux SDK from lnmSnyJi-2H07tBnV... to WdtwlLEce90PjFJ9z... (flutter/engine#37747) * 44e2f5854 [Impeller] Change texture upload pipeline in Vulkan (flutter/engine#37623) * 6a3ad3c14 Roll Skia from 345bceacd298 to 5270b1d26b5f (4 revisions) (flutter/engine#37748) * 01271891c Do not abort if a MultiFrameCodec is unable to allocate a bitmap buffer (flutter/engine#37534) * 54232a4c3 Roll Skia from 5270b1d26b5f to cf967e6b1c00 (5 revisions) (flutter/engine#37751) * 30aa3cc38 [fuchsia][a11y] Set explicit hit regions in flatland embedder (flutter/engine#37338) * da07c33d2 Make NotifyIdle reject close and past deadlines. (flutter/engine#37737) * e3844cc1e Add third_party/dart/third_party/binaryen/src as a dependency (flutter/engine#37749) * aeb2cd95b [Impeller] use SSBOs for gradients where supported (metal/vulkan) (flutter/engine#37654) * e8aa1c192 Roll Skia from cf967e6b1c00 to f1f59de17204 (2 revisions) (flutter/engine#37756) * 4311774fb [Impeller] register modern shaders on Vulkan too (flutter/engine#37757) * 8e4a718d0 Made FlutterTextField that outlive FlutterTextPlatformNode not crash (flutter/engine#37735) * 446a09dfc [macOS] Use consistent filenames for tests (flutter/engine#37755) * 7a390f97c Roll Skia from f1f59de17204 to 12f01bc5b57e (1 revision) (flutter/engine#37760)
…lutter#116620) * 143977b53 Roll Skia from b63a254727f3 to 13e5241ce8b7 (6 revisions) (flutter/engine#38106) * 9554754ac [web:canvaskit] test zero font size (flutter/engine#37916) * 4f22c2789 Roll Skia from 13e5241ce8b7 to aea62b0970c3 (2 revisions) (flutter/engine#38107)
* Remove flaky label * Have test install debug version * Fix test * Undo change * Properly test change * Empty-Commit * Revert testing changes
* Add ListenableBuilder with examples * Add tests * Add tests * Fix Test * Change AnimatedBuilder to be a subclass of ListenableBuilder
* Make some minor changes in preparation for updating the Time Picker to M3 * Revert OutlineInputBorder.borderRadius type change * Revert more OutlineInputBorder.borderRadius changes.
…lutter#116632) * 267f0d849 Roll Skia from aea62b0970c3 to dd3285a80b23 (1 revision) (flutter/engine#38111) * 5ad341776 [Impeller] Remove unused flag enable-impeller-vulkan. (flutter/engine#38109) * 185e2f3d4 Pin the analyzer package version in lib/web_ui (flutter/engine#38114)
…lutter#116633) * 5429243d3 [Impeller Scene] Render imported meshes (flutter/engine#38097) * 67254d6e4 Use announce function in live region (flutter/engine#38084)
@goderbauer I'm very sorry for the inconvenience. |
Fixes #114401
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.