A command palette looks like a text field with a list under it. The list is the easy half. Everything that made mine take three rewrites was underneath the field: a ranking nobody could predict, results that arrived for a query the user had already left, and a keyboard that fought the caret.
I built it with no third-party packages β pure Dart scoring, a ChangeNotifier controller, widgets on top β and ran it at 320 dp with 3.0Γ text. These are the parts that only break once real data, real typing speed and a real keyboard are in the room.
1. The field is part of the score, not a tiebreaker
My first ranker searched the label, the subtitle and the body, and sorted by "how well did the query match". The result: typing new put a note whose third paragraph mentioned "new" above the New note command, because the note's match was contiguous and the command's was not.
The fix was to stop treating fields as equal:
const Map < _Field , int > _fieldWeight = { _Field . label : 100 , _Field . keyword : 88 , _Field .β¦