Skip to content
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

chore: capitalize method for String #4734

Merged
merged 2 commits into from
Oct 28, 2023

Conversation

monsieurtanuki
Copy link
Contributor

What

  • We used a capitalize method for String from an outdated package, and that prevents us from upgrading package flutter_native_splash.
  • The fix is just to implement the same method, as a String extension.
  • When this PR is merged, we can upgrade flutter_native_splash.

Part of

Files

New file:

  • string_extension.dart: extension for String

Impacted file:

  • user_preferences_languages_list.dart: now using the new String extension instead of deprecated library

New file:
* `string_extension.dart`: extension for `String`

Impacted file:
* `user_preferences_languages_list.dart`: now using the new `String` extension instead of deprecated library
extension StringExtension on String {
String capitalize() => isEmpty
? this
: this[0].toUpperCase() + (length == 1 ? '' : substring(1));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify, but replacing (length == 1 ? '' : substring(1) with just substring(1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@g123k I'll try that, but I would be surprised if substring accepted a starting index beyond the string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@g123k Fair enough, it does work! I still don't see the logic behind it though...

@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2023

Codecov Report

Merging #4734 (c2741f4) into develop (2d90250) will decrease coverage by 0.01%.
Report is 18 commits behind head on develop.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           develop   #4734      +/-   ##
==========================================
- Coverage     9.90%   9.90%   -0.01%     
==========================================
  Files          310     312       +2     
  Lines        15807   15808       +1     
==========================================
- Hits          1566    1565       -1     
- Misses       14241   14243       +2     
Files Coverage Δ
...s/preferences/user_preferences_languages_list.dart 5.88% <ø> (ø)
...kages/smooth_app/lib/helpers/string_extension.dart 0.00% <0.00%> (ø)

... and 14 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@g123k g123k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, let's unlock the other upgrade!

@g123k g123k merged commit 37ef119 into openfoodfacts:develop Oct 28, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants