yaml extension error ( Incorrect type. Expected "string".yaml-schema: pubspec.yaml )

Viewed 1968

enter image description here

Recently i created a flutter project and open the "YAML" ,getting some error from "YAML" extension , How can i solve this , is the only solution uninstall the extension or how to overcome this without uninstalling this extension

tried flutter clean , repair etc..... but nothing was helpful ,

getting error are

1 Incorrect type. Expected "string".yaml-schema: pubspec.yaml

2 Property flutter is not allowed.yaml-schema: pubspec.yaml

3 Property cupertino_icons is not allowed.yaml-schema: pubspec.yaml

4 Property flutter_test is not allowed.yaml-schema: pubspec.yaml

5 ect........

using flutter version is 2.8.1

"YAML"(extension) version v1.5.0

7 Answers

I'm having the same issue with VSCode since this afternoon, everything worked well before. I've tried forcing the schema via # yaml-language-server: $schema=<urlToTheSchema> and yaml.schemas setting, but no luck.

Edit: could be related to upgrading to yaml extension v1.5.0 (cf: https://github.com/redhat-developer/vscode-yaml/issues/708) Temporarily downgrading back to 1.4.0 no longer throws errors.

The YAML extension is using an incorrect schema to validate your YAML file. Ensure that:

  • your file does contain a correct # yaml-language-server: $schema=<urlToTheSchema> comment or at least does not contain a wrong one.
  • your yaml.schemas setting does not associate your file via glob pattern with an incorrect schema.

The correct schema would be https://json.schemastore.org/pubspec.json. See also Associating Schemas.

I reload the YAML extension and the error gone

i have uninstall yaml extention and reinstall and re-open vs code it fixes the issue for meenter image description here

For me, in the extensions of VsCode, I looked for YAML and I saw there is a "reload required" next to it. did the reload and the errors went away. It is all fixed now.

Please update VSCode's YAML extension to at least 1.5.1 to resolve the error. Flutter will work as it is with the errors too.

Related