-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Avoid cumbersome formatter workaround #6573
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 "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use 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. |
RegExp(r' *0x([A-F0-9]{2}),? *\n? *'), (Match m) => '${m[1]}\n')) | ||
.map<int>((String b) => int.parse(b, radix: 16)) | ||
.toList(); | ||
]; |
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.
Another, still simpler than the original, workaround would be:
final String _imageBytesString =
'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49'
'\x48\x44\x52\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06'
'\x00\x00\x00\x1F\x15\xC4\x89\x00\x00\x00\x0A\x49\x44'
'\x41\x54\x78\x9C\x63\x00\x01\x00\x00\x05\x00\x01\x0D'
'\x0A\x2D\xB4\x00\x00\x00\x00\x49\x45\x4E\x44\xAE';
final List<int> _transparentImage = [..._imageBytesString.codeUnits];
Having a full, formatted string, and parsing it using RegExp, just to get to some bytes, feels a little like overkill.
|
||
// Convert the string representing the hexidecimal bytes in the image into | ||
// a list of integers that can be consumed as image data in a stream. | ||
final List<int> _transparentImage = const LineSplitter() |
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.
Some possible improvements, for any similar code:
- For
const LineSplitter().convert(...)
, one can just useLineSplitter.split(...)
. - It's easier to just match the numbers, and then work on
allMatches
, than to try to remove what's not numbers:final List<int> _transparentImage = RegExp(r'0x([A-F0-9]{2})').allMatches(_imageBytesAsString) .map((b) => int.parse(b[1], radix: 16)) .toList();
@lrhn Are you planning on updating this to pass the analyzer CI check? |
If a list shouldn't be formatted with one element on each line, a single EOL-comment inside is enough to disable the formatter. Much simpler.
Merged to head, removed unused import. |
You're still missing a type specifier on the list, so it fails analysis with Flutter settings. |
Added type to list literal. Now I'm half-expecting to get a warning about having types on both sides of the |
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
auto label is removed for flutter/packages/6573, due to This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.
|
@lrhn You might want to request being added to flutter-hackers. Meanwhile, @domesticmouse could you approve this? |
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
flutter/packages@11e192a...586faa6 2024-06-05 [email protected] [google_sign_in_web] Update button_tester to use web_only library. (flutter/packages#6868) 2024-06-05 [email protected] Roll Flutter from c246ecd to 27e0656 (17 revisions) (flutter/packages#6875) 2024-06-05 [email protected] [path_provider] Skip verifying sample file on macOS (flutter/packages#6874) 2024-06-05 [email protected] [google_maps_flutter] Custom marker size improvements (flutter/packages#4055) 2024-06-05 [email protected] [rfw] Material slider widget (flutter/packages#6610) 2024-06-04 [email protected] [ci] Manual roll Flutter to c246ecd (84 revisions) + fixes (flutter/packages#6863) 2024-06-04 [email protected] Correcting the typo of Flutter in projects (flutter/packages#6850) 2024-06-04 [email protected] [google_maps_flutter] Custom marker size improvements - platform impls (flutter/packages#6826) 2024-06-04 [email protected] Avoid cumbersome formatter workaround (flutter/packages#6573) 2024-06-04 [email protected] Clean Xcode project before analyzing and testing (flutter/packages#6842) 2024-06-03 [email protected] [pigeon] Kotlin/Java method overloading for the `setUp` method (flutter/packages#6843) 2024-06-03 [email protected] [url_launcher] Add support for setting show title on Chrome Custom Tabs (flutter/packages#6097) 2024-06-03 [email protected] Revert "Roll Flutter from c85fa6a to 7eebe29 (#6836)" (flutter/packages#6860) 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-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: 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
If a list shouldn't be formatted with one element on each line, a single EOL-comment inside is enough to disable the formatter. Much simpler.
If a list shouldn't be formatted with one element on each line, a single EOL-comment inside is enough to disable the formatter. Much simpler.