Home > Mobile >  How to fix "Error detected in pubspec.yaml: Error on line 74, column 2: Expected ':'.
How to fix "Error detected in pubspec.yaml: Error on line 74, column 2: Expected ':'.

Time:03-25

when I press (Ctrl s) to save my pubspec.yaml on my flutter project, this display in output:

enter image description here

what's the problem? and how to fix it?

CodePudding user response:

Use this extension pubspec assist to your vscode IDE. Once installed go to pubspec.yaml and open command palette (Ctrl Shift P) and search "Pubspec Assist" and select "sort all depecdencies"

YAML has formatting rules. Learn more about YAML by googling.

CodePudding user response:

Just Remove the : from infront of fonts and indent it such that only 2 space from the starting point.

fonts:
  - family: Schyler
    fonts:
      - asset: fonts/Schyler-Regular.ttf
      - asset: fonts/Schyler-Italic.ttf

Here each children has 2 space far indentation from its parent.

  • Related