発生したエラー
-
pubspec.yamlにカスタムフォントをセットした後にflutter runを試したところ、下記のエラーが発生した。
Error on line 32, column 5 of pubspec.yaml: A dependency may only have one source.
╷
32 │ ┌ sdk: flutter
33 │ │ fonts:
34 │ │ - family: NotoSansJP
35 │ │ fonts:
36 │ │ - asset: static/fonts/NotoSansJP-Regular.ttf
37 │ │
38 │ │ # The following adds the Cupertino Icons font to your application.
39 │ │ # Use with the CupertinoIcons class for iOS style icons.
40 │ │ cupertino_icons: ^1.0.8
│ └──^
╵
解決策
-
flutter:の場所が違った。
誤.yaml
dependencies:
flutter:
sdk: flutter
#NG
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
rename_app: ^1.6.5
change_app_package_name: ^1.5.0
正.yaml
flutter:
#✅OK
fonts:
- family: NotoSansJP
fonts:
- asset: static/fonts/NotoSansJP-Regular.ttf
# 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.