0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【flutter攻略】A dependency may only have one source.の解決方法

Posted at

font_awesome_flutterでアイコンを表示しようとしたがめちゃエラー出る。

エラー文 : A dependency may only have one source.

現在のコード

main.dart
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
pubspec.yaml
dependencies:
  flutter:
    sdk: flutter
    font_awesome_flutter: ^8.11.0

yamlファイルってインデントを使って構造を表現するので、インデントのミス一つで機能しなくなる。
なので下記のように変更しましょう。

pubspec.yaml
dependencies:
  flutter:
    sdk: flutter
  font_awesome_flutter: ^8.11.0

yamlファイルを触ったら必ずflutter pub getを実行し、再度読み込み。
Flutter Demo Home Page.png

可愛いアイコンが出てきましたね。解決解決。
packageを読み込む際は、必ずインデントに注意してコードを書くようにしましょう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?