Flutter 添加外部包(package)报错

Error on line 25, column 4 of pubspec.yaml: Expected a key while parsing a block mapping.
  ╷                                                                    
25 │    cupertino_icons: ^0.1.2                                         
  │    ^                                                               
  ╵         

解决方案:

原因是因为在添加外部包的时候,名称没有对其.有空格导致的报错。

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 [首字母前边有空格会导致报错]
  english_words: ^3.1.0 [首字母前边有空格会导致报错]

dev_dependencies:
  flutter_test:
    sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# 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

你可能感兴趣的:(Flutter 添加外部包(package)报错)