pavan paraskar
pavan paraskar

Reputation: 41

Error on line 40, column 4 of pubspec.yaml: Expected a key while parsing a block mapping. assets: ^

To add assets to your application, add an assets section, like this:

assets: - images/contact.png # - images/a_dot_ham.jpeg

Upvotes: 2

Views: 4824

Answers (3)

Erick Lesser Diaz
Erick Lesser Diaz

Reputation: 21

I had the same error

my problem was that uses-material-design: and assets: were misaligned

   uses-material-design: true  //column 3 

    # To add assets to your application, add an assets section, like this:
    assets://column 4

The simple solution was to make sure that my assets section was aligned with my use materials design section, in other words they should be put together in the same column as the following code:

   uses-material-design: true  //column 3

    # To add assets to your application, add an assets section, like this:
   assets://column 3

Upvotes: 2

Dshay khan
Dshay khan

Reputation: 1

just set the indentation name: flutter_demo1 description: A new Flutter application. version: 1.0.0+1

environment: sdk: ">=2.1.0 <3.0.0"

dependencies: flutter: sdk: flutter

cupertino_icons: ^0.1.2

dev_dependencies: flutter_test: sdk: flutter

flutter: uses-material-design: true assets: - images/

Upvotes: 0

Aravindh Kumar
Aravindh Kumar

Reputation: 1243

Include all assets in assets folder located in the application directory

my pubspec file looks like

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.io/assets-and-images/#resolution-aware.

use it like

Image.asset('assets/logo.png')

make sure to indented properly to avoid error.

Upvotes: 1

Related Questions