How to show spellchecker(wrong spelling with underline) in TextFormField in Flutter? - flutter

In my application I have a story line - Forgive user typos in search makes it effortless for the users. So what exactly I want when I type something in TextFormField it should do spellchecker. Is there is any solution for that in flutter? Kindly find the attached screenshot.

You should use a spellcheck api service for this like Bing Spell Check API it will return the mistakes in the text and you can underline them. Here is the respond of your text;
{
"_type": "SpellCheck",
"flaggedTokens": [
{
"offset": 14,
"token": "Sofyware",
"type": "UnknownToken",
"suggestions": [
{
"suggestion": "Software",
"score": 0.9140160264956476
}
]
}
]
}
here is some APIs you can check them out and select which one works for you.
And here is a package include english words that you can check if the word inside it; https://pub.dev/packages/list_english_words

This feature has landed in Flutter 3.7. To use it, add this parameter to your EditableText or TextField:
spellCheckConfiguration: kIsWeb ? null : SpellCheckConfiguration().
(The spell check configuration currently seems to break on web)

Related

Studio 3T for MongoDB unable to insert multiple object at once in json document in a collection

In Studio 3T i have created the collection in which i am adding a document after which popup window appears Titled >>Insert JSON Document<< to add the data in the document then i wrote these items.
{
"_id" : "5c18e1892998bdb3b3d355bf",
"title" : "REST",
"content" : "REST is short for REpresentational State Transfer. IIt's an architectural style for designing APIs."
}
{
"_id" : ObjectId("5c139771d79ac8eac11e754a"),
"title" : "API",
"content" : "API stands for Application Programming Interface. It is a set of subroutine definitions, communication protocols, and tools for building software. In general terms, it is a set of clearly defined methods of communication among various components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer."
}
{
"_id" : ObjectId("5c1398aad79ac8eac11e7561"),
"title" : "Bootstrap",
"content" : "This is a framework developed by Twitter that contains pre-made front-end templates for web design"
}
{
"_id" : ObjectId("5c1398ecd79ac8eac11e7567"),
"title" : "DOM",
"content" : "The Document Object Model is like an API for interacting with our HTML"
}
{
"_id" : "5c18f35cde40ab6cc551cd60",
"title" : "Jack Bauer",
"content" : "Jack Bauer once stepped into quicksand. The quicksand couldn't escape and nearly drowned.",
"__v" : 0
}
after that when i click the button add document, another popup appears which is Titled >>JSON Validation<< under which "Orphan character detected at line 8, col 1" shows. And i am not able to insert these documents at once.
How could i insert all these object at once in the document ?
It's a limitation, unsupported till the date. You could run a insertMany query
db.collection.insertMany([{doc1}, {doc2}])
Github link
Alternatively you can import documents if you don't want to run a direct query.
I also faced with same issue when I was trying to insert multiple objects at once. My solution was to add the objects individually. It know it takes time but I could not find any other way to do it.
Copy your JSON documents to the clipboard, then go to your collection and Control/Command V to paste the clipboard into the collection. You'll be prompted "Import documents from clipboard" - click OK and when done, refresh your view to see the newly imported documents.
Background: The Insert JSON Document, is, as it says, for single JSON documents. The error you see is because it is detecting a second JSON document beginning. Multiple JSON Document insertion is better handled by import, and if you paste JSON documents into a collection, it automatically triggers an import from clipboard.
It's easy. Select all the JSON data that you want to enter into the collections, and Copy it to the clipboard (Ctrl+C on PC, or Command+C on MAC).
In Studio3T right click on the document where you want to insert items.
From the menu choose "Import Data..."
Leave the first option pre-selected "JSON - Mongo shell ..."
Confirm the selection by clicking "Configure"
Click on "Paste from clipboard" and click on the green "run" button.
That's it :) and it works as of Oct 2, 2022.
In the document window:
Right click > Paste Document(s) or simply CTRL + V
that will insert all the documents you have copied.
create json file and add your data in it.
[
{
"title": "REST",
"content": "REST is short for REpresentational State Transfer. It's an architectural style for designing APIs."
},
{
"title": "API",
"content": "API stands for Application Programming Interface. It is a set of subroutine definitions, communication protocols, and tools for building software. In general terms, it is a set of clearly defined methods of communication among various components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer."
},
{
"title": "Bootstrap",
"content": "This is a framework developed by Twitter that contains pre-made front-end templates for web design"
},
{
"title": "DOM",
"content": "The Document Object Model is like an API for interacting with our HTML"
},
{
"title": "Jack Bauer",
"content": "Jack Bauer once stepped into quicksand.The quicksand couldn't escape and nearly drowned."
}
]
2.In studio 3T, right click on your document and select import data
as given here
select JSON
4.click on add source and add your json file.
click on RUN to add your data.

VS Code keybinding: Accept quickfix codeAction

I'm trying to implement a small function by adding a shortcut for auto-correcting the last misspelled word, and this is what I get currently:
{
"key": "cmd+l",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"cSpell.goToPreviousSpellingIssue",
"editor.action.quickFix",
"workbench.action.navigateToLastEditLocation",
"acceptSelectedSuggestionOnEnter",
"acceptSelectedSuggestion"
]
}
},
The idea is simple: jump back to the first misspelled word, and just select the first suggestion my spelling checker gives me, finally jump back to the previous edited position.
The code above is using multiCommand plug-in. Question is that I can't find any keystroke events to let me actually select the first suggestion my spelling checker gives me.
As in the config, I'm using cSpell for checking my spelling. To be specific, after I hit cmd+l, this is what I get:
snap shot
Clearly, I manage to move to the previous spelling issue, and evoke quickFix to let the suggestion widget pop up, and then move my cursor back to where I was initially. Hence, the only problem is what is the event to select that suggestion?
Really appreciate every helps, or if there is a better method to do the same thing please tell me! (I have tried every keyword I can think of, and there are not many references out there both in the official document from VS Code and google)
Because the quickfix menu is a different beast than a suggestions menu, the nextSuggestion or acceptSuggestion type of commands will not work in it. There is an open issue for navigation commands in the quickfix menu, see Missing keybinding for navigation in Quick Fix contextual menu
.
But you can get what you want another way. I found Keybinding for applying a specific code action and in it is a method for applying a quickfix with a command:
{
"key": "ctrl+shift+r ctrl+e",
"command": "editor.action.codeAction",
"args": {
"kind": "refactor.extract.function",
"apply": "first"
}
}
Valid values for "apply":
"first" — Always automatically the first available code action.
"ifSingle" — Default. Automatically the code action if only one is available. Otherwise, show the context menu.
"never" — Always show the code action context menu, even if only a single code action is available.
Adapting that for your use case, try this:
{
"key": "cmd+l", // "ctrl+l" for Windows
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"cSpell.goToPreviousSpellingIssue",
{
"command": "editor.action.codeAction",
"args": {
"kind": "quickfix",
"apply": "first" // you indicated you want the first choice
}
},
// "workbench.action.navigateToLastEditLocation"
"cursorUndo" // better than the above I believe
]
}
}

How do I create a custom Semantic Token for VSCode?

I'm creating a color theme and I found out that the only way to target function parameters with italic is by using semantic highlight. The problem is that since semantic highlight overrides some settings, I lost the ability to target support.function.console - the "log" of console.log, for instance.
.log is a member.defaultLibrary, but if I target that by semantic, some other things would also be styled with the same color. That wouldn't be bad if member.defaultLibrary wasn't so inconsistent, some things you would expect to be styled, is not, which leads to inconsistency, which is certainly not desirable.
querySelector() is styled by member.defaultLibrary but not querySelectorAll(), for instance. I also tried to not use anything that can be overridden by semantics but then, it creates too many exceptions and some functions and methods would be let without any style, which is much worse.
I've tried Semantic Token Classification and tried to add a custom semantic token to the package.json file of the extension but I don't know how to "wire" that up:
{
"contributes": {
"semanticTokenTypes": [
{
"id": "consoleSupport",
"description": "console support"
}
],
"semanticTokenScopes": [
{
"scopes": {
"consoleSupport": ["support.function.console"]
}
}
]
}
}
When using development host, it does recognize the "new" consoleSupport when I try to add to "semanticTokenColors", it suggests the auto-complete, so I'm probably half-way there but I don't know how to actually create the new token and how to make it work.

Multi scope selection for textMateRules

Trying to make the move from webstorm to vscode.
Im trying to figure out how to target textMateRules more accurately.
Specifically demanding more than one scope match.
I read somewhere that you did it like this, but it gets overwritten by the default entity.name.function.
"scope": [
"entity.name.function meta.method.declaration"
],
Any help appriciated.
I had not realized ordering was important.
"scope": [
"meta.method.declaration entity.name.function"
],
Did the trick.
In my VS Code (1.63.2) for multiple scopes I use this code:
"scope": [
"entity.name.function",
"meta.method.declaration"
],

What are the rules for class names in IBM Watson Visual Recognition service?

I'm exploring IBM Watson Visual Recognition service and when I create a classifier using classnames like 'black-dog' (i.e. black-dog_positive_example), this classname is later returned as 'black_dog' (with underscore replacing dash) when I classify an image using the /v3/classify endpoint.
But when I retrieve the classifier details with the /v3/classifiers/{classifier_id} the class is correctly listed as 'black-dog'.
So, my result for GET /v3/classifiers/{classifier_id} is like:
{
"classifier_id": "dog_561932172",
"name": "dog",
"owner": "xxxxxxxx-xxx-xxx-xxx-xxxxxxxxxxxx",
"status": "ready",
"created": "2016-07-30T22:06:39.327Z",
"classes": [
{"class": "black-dog"}
]
}
While my result for GET /v3/classify is
{
"custom_classes": 1,
"images": [
{
"classifiers": [
{
"classes": [
{
"class": "black_dog",
"score": 0.546941
}
],
"classifier_id": "dog_561932172",
"name": "dog"
}
],
"image": "20160620_142113.jpg"
}
],
"images_processed": 1
}
So is this expected or a defect? Should I avoid using "-" in class names? Are there any other rules for the value of a classname?
Update:
Updated via Matt's answer.
Talked with the support team, and it is indeed a bug. Here was their response:
Thanks for pointing this out. I reproduced and confirmed with dev team, and we do consider this inconsistency between the listed class name and the class name in results is a bug.
And this is because the class name been altered in result from what is submitted.
I have raised a ticket for tracking on this. According to developer, currently the output can be either a document to list the substitutions or find a way to remove them.
...so they are currently working on it.
Are there any other rules for the value of a classname?
We made an update, and the service should no longer modify any class names like replacing a dash with an underscore. Instead, it will not accept class names with any of these characters for custom learning: \,|,*,{,},$,-,/,',`,"
(You'll see the dash is included in there.) Spaces are acceptable. The update is not retroactive, so existing class names that were modified during training are not affected.