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

Time:03-08

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

CodePudding user response:

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.

CodePudding user response:

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.

  • Related