Skip to content

Remove unused context parameter #124254

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

Merged
merged 8 commits into from
Apr 18, 2023

Conversation

justinmc
Copy link
Contributor

@justinmc justinmc commented Apr 5, 2023

I noticed a context parameter that was unused in these methods, so I've removed them. This could be a breaking change, but because it was just introduced, it's probably unlikely.

@justinmc justinmc self-assigned this Apr 5, 2023
@flutter-dashboard flutter-dashboard bot added a: text input Entering text in a text field or keyboard related problems f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Apr 5, 2023
@justinmc justinmc requested a review from camsim99 April 5, 2023 19:04
@justinmc justinmc marked this pull request as ready for review April 12, 2023 22:21
Copy link
Contributor

@camsim99 camsim99 left a comment

Choose a reason for hiding this comment

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

This seems legitimate to me. Thanks!

@@ -85,4 +86,29 @@ void main() {
final double toolbarY = tester.getTopLeft(findSpellCheckSuggestionsToolbar()).dy;
expect(toolbarY, equals(expectedToolbarY));
});

test('buildButtonItems builds only a delete button when no suggestions', () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Great addition!

void main() {
TestWidgetsFlutterBinding.ensureInitialized();

testWidgets('buildButtonItems builds a "No Replacements Found" button when no suggestions', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

Great addition!!

@justinmc justinmc merged commit 9d68831 into flutter:master Apr 18, 2023
@justinmc justinmc deleted the build-button-items-context branch April 18, 2023 17:31
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 18, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Apr 18, 2023
flutter/flutter@15cb1f8...42fb0b2

2023-04-18 [email protected] Fix text theme dart fix cases (flutter/flutter#125052)
2023-04-18 [email protected] Update the copy icon in snippets and samples to use the standard one (flutter/flutter#123651)
2023-04-18 [email protected] Remove unused context parameter (flutter/flutter#124254)
2023-04-18 [email protected] iOS spell check cursor placement (flutter/flutter#124875)
2023-04-18 [email protected] Roll Flutter Engine from d2973619074e to 55bb065c607b (1 revision) (flutter/flutter#125047)
2023-04-18 [email protected] Stop running "_impeller_" benchmark variants (flutter/flutter#125044)
2023-04-18 [email protected] Roll Packages from 0277f2a to faf53fb (7 revisions) (flutter/flutter#125040)
2023-04-18 [email protected] Roll Flutter Engine from c4396f9f602f to d2973619074e (6 revisions) (flutter/flutter#125039)
2023-04-18 [email protected] Roll pub packages (flutter/flutter#125005)
2023-04-18 [email protected] [InputDatePickerFormField] adds acceptEmptyDate to InputDatePickerFormField Widget (flutter/flutter#124143)
2023-04-18 [email protected] relayout active ListWheelScrollView children every performLayout (flutter/flutter#124476)
2023-04-18 [email protected] Roll Flutter Engine from 4a603aaff32e to c4396f9f602f (2 revisions) (flutter/flutter#125007)
2023-04-18 [email protected] Roll Flutter Engine from 20034a8d62c4 to 4a603aaff32e (2 revisions) (flutter/flutter#125004)
2023-04-18 [email protected] Add optional axis specifier to static scrollable methods (flutter/flutter#124894)
2023-04-17 [email protected] Update usage of standalone`pub` executable in flutter_tools testing docs (flutter/flutter#124898)
2023-04-17 [email protected] Add Harish Anbalagan to AUTHORS (flutter/flutter#124684)
2023-04-17 [email protected] Roll Flutter Engine from b2d07388ceb6 to 20034a8d62c4 (7 revisions) (flutter/flutter#125001)
2023-04-17 [email protected] Add an example for SearchBar (flutter/flutter#124992)
2023-04-17 [email protected] SelectionContainer's listeners can remove itself during listener callâ�¦ (flutter/flutter#124624)

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
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@werainkhatri
Copy link
Member

shouldn't there be a lint to prevent this from happening? unused parameter lint?

@justinmc
Copy link
Contributor Author

I agree, but in this case it's a public API, and we could potentially be providing the parameter to Flutter users even though it's not used internally in the framework itself.

I'm not sure if we have a lint that would catch it for a private API. We should.

@Hixie
Copy link
Contributor

Hixie commented Apr 20, 2023

This is a surprising change to me. Generally all build methods in public APIs should have the context, otherwise they can't do things like MediaQuery.of or CupertinoTheme.of or whatnot. Is this not that kind of build method?

@justinmc
Copy link
Contributor Author

Hmm I'll look at this more closely tomorrow, maybe this is just a brain fart on my part as I tried to clean this up. I think I didn't think of it as a typical builder because it doesn't return a Widget. Also there is editableTextState.context, but maybe that's not what should be used here.

@Hixie
Copy link
Contributor

Hixie commented Apr 21, 2023

(to be clear i'm not familiar with this code and am quite ready to believe these aren't normal builders and that it's fine to make this change)

@justinmc
Copy link
Contributor Author

Ok after taking a closer look, I'm going to advocate for keeping it as-is (no context parameter). These buildButtonItems methods are "building" information about the buttons, which are later turned into widgets elsewhere. They shouldn't need to look up things like MediaQuery or Theme. The one reason to use context would be for localizations, but I think it makes sense to get that from editableTextState.

Maybe the build name was a misnomer here. I think these methods might be more analogous to getEditableButtonItems than a builder.

I'm definitely open to be proven wrong here though. I'll keep an eye out if anyone opens an issue about this or shows confusion for lack of a BuildContext parameter. Also, @camsim99 you're the original author here, let me know if you think I'm not on track with what you intended for these.

@reidbaker reidbaker mentioned this pull request Apr 21, 2023
8 tasks
justinmc added a commit to justinmc/flutter that referenced this pull request Apr 25, 2023
Tidying up the spell check API.
itsjustkevin pushed a commit that referenced this pull request Apr 26, 2023
This is a cherry pick of 8 of my recent spell check bug fixes into the
beta branch.

  1. #124259
  2. #124875
  3. #124254
  4. #124899
  5. #124895
  6. #125162
  7. #124897
  8. #125432

This is the behavior of spell check with these changes:

| Screenshot | Video |
| --- | --- |
| <img
src="https://user-images.githubusercontent.com/389558/234087650-bcd62c89-03e7-427d-afc5-0fe8f96a5f80.png"
/> | <video
src="https://user-images.githubusercontent.com/389558/234087667-651b0fde-348c-467e-ba00-27b6b3966a27.mov"
/> |

CC @itsjustkevin @leighajarett
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
flutter/flutter@15cb1f8...42fb0b2

2023-04-18 [email protected] Fix text theme dart fix cases (flutter/flutter#125052)
2023-04-18 [email protected] Update the copy icon in snippets and samples to use the standard one (flutter/flutter#123651)
2023-04-18 [email protected] Remove unused context parameter (flutter/flutter#124254)
2023-04-18 [email protected] iOS spell check cursor placement (flutter/flutter#124875)
2023-04-18 [email protected] Roll Flutter Engine from d2973619074e to 55bb065c607b (1 revision) (flutter/flutter#125047)
2023-04-18 [email protected] Stop running "_impeller_" benchmark variants (flutter/flutter#125044)
2023-04-18 [email protected] Roll Packages from 0277f2a to faf53fb (7 revisions) (flutter/flutter#125040)
2023-04-18 [email protected] Roll Flutter Engine from c4396f9f602f to d2973619074e (6 revisions) (flutter/flutter#125039)
2023-04-18 [email protected] Roll pub packages (flutter/flutter#125005)
2023-04-18 [email protected] [InputDatePickerFormField] adds acceptEmptyDate to InputDatePickerFormField Widget (flutter/flutter#124143)
2023-04-18 [email protected] relayout active ListWheelScrollView children every performLayout (flutter/flutter#124476)
2023-04-18 [email protected] Roll Flutter Engine from 4a603aaff32e to c4396f9f602f (2 revisions) (flutter/flutter#125007)
2023-04-18 [email protected] Roll Flutter Engine from 20034a8d62c4 to 4a603aaff32e (2 revisions) (flutter/flutter#125004)
2023-04-18 [email protected] Add optional axis specifier to static scrollable methods (flutter/flutter#124894)
2023-04-17 [email protected] Update usage of standalone`pub` executable in flutter_tools testing docs (flutter/flutter#124898)
2023-04-17 [email protected] Add Harish Anbalagan to AUTHORS (flutter/flutter#124684)
2023-04-17 [email protected] Roll Flutter Engine from b2d07388ceb6 to 20034a8d62c4 (7 revisions) (flutter/flutter#125001)
2023-04-17 [email protected] Add an example for SearchBar (flutter/flutter#124992)
2023-04-17 [email protected] SelectionContainer's listeners can remove itself during listener callâ�¦ (flutter/flutter#124624)

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
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: text input Entering text in a text field or keyboard related problems f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants