Skip to content

Suggest the Characters API when completing callbacks for handling user-generated text #41677

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

Open
InMatrix opened this issue Apr 27, 2020 · 4 comments
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-completion Issues with the analysis server's code completion feature devexp-server Issues related to some aspect of the analysis server P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@InMatrix
Copy link
Collaborator

This is a feature request for the Dart Analyzer to augment its current completion behavior for certain known callbacks in Flutter that handle user-generated text (e.g., https://api.flutter.dev/flutter/material/TextField/onChanged.html).

Background

The characters package was recently introduced to address Dart String's limitations of manipulating extended grapheme clusters (dart-lang/language#34). However, it requires the user to get out of their way to look for it and add it to their projects. This barrier is likely to cause continued use of the String API in cases where the characters package ought to be used to avoid breaking emojis and non-English text.

Request

As part of a larger plan to make the Characters API more discoverable when writing text manipulation code, the Dart Analyzer could suggest the API when autocompleting the callback template for handling user entered text. For example everything in this snippet after the user autocompletes on onChanged can potentially be populated for them:

TextField(
  onChanged: (String value) {
  // Converting String to Characters to handle emojis 
  // and non-English characters more robustly.
  var myText = value.characters;     
  // Do something with myText 
  }
)

This request, if accepted, depends on exposing the Characters package in Flutter's public API as tracked here: flutter/flutter#55593.

@mit-mit mit-mit added the legacy-area-analyzer Use area-devexp instead. label May 1, 2020
@srawlins srawlins added devexp-completion Issues with the analysis server's code completion feature devexp-server Issues related to some aspect of the analysis server labels Jun 16, 2020
@srawlins srawlins added the P3 A lower priority bug or feature request label Nov 10, 2020
@InMatrix
Copy link
Collaborator Author

The dependency flutter/flutter#55593 has been satisfied. Is there any chance to increase the priority of this issue?

@bwilkerson
Copy link
Member

I'm guessing that String.characters is an extension method. If that's the case then another aspect of this would be to improve analyzer's ability to suggest extension methods, which at the moment is very limited.

@devoncarew For the priority question.

@bwilkerson
Copy link
Member

If we do something here, we should consider adding an annotation that can be used to mark such APIs so that the system is more general.

@InMatrix
Copy link
Collaborator Author

If we do something here, we should consider adding an annotation that can be used to mark such APIs so that the system is more general.

I like the idea. It will allow anyone writing a text input widget to take advantage of this auto completion feature.

@srawlins srawlins added the type-enhancement A request for a change that isn't a bug label Nov 29, 2021
@scheglov scheglov assigned scheglov and unassigned scheglov Mar 5, 2024
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-completion Issues with the analysis server's code completion feature devexp-server Issues related to some aspect of the analysis server P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants