Flutter, файл pubspe c .yaml показывает некоторые ошибки - PullRequest
0 голосов
/ 09 мая 2020

Я не знаю, что происходит, но я не могу вставить изображение через изображение актива, используя pubspec.yaml файл. Pub get не загружает зависимости.

Пожалуйста, помогите мне. Я веду проект флаттера.

Вот код pubspec.yaml файла

name: mi_card_flutter
description: A new Flutter application.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter
flutter:
  uses-material-design: true
  assets:
    images/khushi.jpg

Ошибка:

Ошибка обнаружена в pubspe c .yaml: Ожидаемые "активы" быть списком, но есть изображения / (String). Исправьте файл pubspe c .yaml по адресу C: \ Users \ khush \ AndroidStudioProjects \ mi_card_flutter \ pubspe c .yaml Процесс завершен с кодом выхода 1

enter image description here

Ответы [ 3 ]

0 голосов
/ 09 мая 2020

Пожалуйста, напишите в assets в pubspec.yaml файле, как показано ниже

dev_dependencies:
  flutter_test:
    sdk: flutter
flutter:
  uses-material-design: true
  assets:
    images/khushi.jpg

вместо этого

dev_dependencies:
  flutter_test:
    sdk: flutter
flutter:
  uses-material-design: true
  assets:
    - images/khushi.jpg
0 голосов
/ 09 мая 2020

Наконец, потратив 3 часа на это сомнение, я получил ответ. Я запустил pub get из терминала, и он сработал!

0 голосов
/ 09 мая 2020

Ваш отступ images/kushi.jpg неправильный.

Попробуйте использовать приведенный ниже код: Хорошо работает:

name: mi_card_flutter
description: A new Flutter application.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter
flutter:
  uses-material-design: true
  assets:
    -images/

Надеюсь, это поможет.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...