-
Notifications
You must be signed in to change notification settings - Fork 91
Autocomplete features #276
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
base: main
Are you sure you want to change the base?
Conversation
|
@waseemdev hello, thank you. I just started allocating time on reviews for this project. I can't resolve conflicts in your forked branch. Can you do it? |
| Mode? mode; | ||
| List<String> blacklist = []; |
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.
autocompleter.dart declares concrete fields instead of abstract accessors
Problem: Autocompleter currently has
Mode? mode;
List blacklist = []; DefaultAutocompleter implements getters/setters for mode and blacklist (and uses @OverRide). You cannot override a concrete field with getters/setters — this causes analyzer/compile errors.
Fix: make those members abstract (declare getters/setters) in Autocompleter. Example replacement:
Mode? get mode; set mode(Mode? value);
List get blacklist; set blacklist(List value);
(Keep the other abstract methods: setText, getSuggestionItems, replaceText.)
Example:
import 'package:flutter/material.dart'; import 'package:highlight/highlight_core.dart';
abstract class Autocompleter { Autocompleter();
// Language mode used to extract keywords from highlight Mode Mode? get mode; set mode(Mode? value);
// Words to exclude from suggestions List<String> get blacklist; set blacklist(List<String> value);
/// Sets the [text] to parse all words from. /// Multiple texts are supported, each with its own [key]. /// Use this to set current texts from multiple controllers. void setText(Object key, String? text);
/// Returns items ready to be shown in popup based on current editing value Future<List<SuggestionItem>> getSuggestionItems(TextEditingValue value);
/// Replace selection/value using picked suggestion item. /// Returns a new TextEditingValue to assign to controller.value, or null if nothing changed. TextEditingValue? replaceText( TextSelection selection, TextEditingValue value, SuggestionItem item, ); }
class SuggestionItem { final String text; final String displayText; final dynamic data;
| @@ -0,0 +1,210 @@ | |||
| import 'package:autotrie/autotrie.dart'; | |||
| import 'package:flutter/material.dart'; | |||
| import 'package:highlight/highlight_core.dart'; | |||
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.
Autocompleter imports package:highlight/highlight.dart while DefaultAutocompleter imports package:highlight/highlight_core.dart. Choose the correct import that exposes Mode (typically highlight_core.dart) and use it in autocompleter.dart so Mode is known.
| .toList(); | ||
| } | ||
|
|
||
| Future<List<String>> getSuggestions(String prefix) async { |
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.
Decide whether getSuggestions(String) should be part of the Autocompleter interface (currently only DefaultAutocompleter exposes it; CodeController uses getSuggestionItems, so this is optional).
| @@ -1,133 +1,29 @@ | |||
| import 'package:autotrie/autotrie.dart'; | |||
| import 'package:highlight/highlight_core.dart'; | |||
| import 'package:flutter/material.dart'; | |||
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.
Since autocompleter.dart is a non-UI, library-level file (it only needs the types, not Material widgets), prefer the smaller import for TextEditingValue and TextSelection to avoid pulling Material into a low-level lib file: import 'package:flutter/services.dart';
Hi,
Here are two commits:
I made
Autocompleterabstract class and renamed default one toDefaultAutocompleter, so user can create its own implementationSuggestionItemto be more customizable than justString, in some cases the displayed text in the popup list can be different than the actual code.made the popup list customizable so user can use his own widget using
autocompleteListBuilder.caretPadding,autocompletePopupMaxHeight,autocompletePopupMaxWidth) to be fields inCodeEditorwidget