6
3

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 3 years have passed since last update.

FlutterのCupertinoIconsは不十分なので、直接IconDataを使うべし

Last updated at Posted at 2020-04-30

CupertinoIcons探しにくい問題

Material Design準拠のMaterial Iconの場合であれば、公式のIcon一覧から気に入ったアイコンの名前を使えば良いので楽ですが、CupertinoIconsを使用したい場合、そうはいきません。

例えば、ハンバーガーメニューのCupertinoIconを使用したいと思っても、menuなどで出てこなく、嫌になります。(今現在も何なのかわからず...。そもそもあるのか?)

cupertino_iconsのパッケージ情報を見ると、アイコン一覧が画像になっていて期待させますが、そこに書かれているのは名前ではない。。。

cupertino_icons.png

しかし、これを使えば格段に楽に、CupertinoIconを使うことができました。

解決策:直接 IconData を指定すれば良い

上記の画像には、各アイコンの上にf394などのコードが書かれています。

つまり、それを使って直接IconDataを呼び出せば良いです。

以下は、メニューアイコンの例。

Icon(
  IconData(
    0xf394,
    fontFamily: CupertinoIcons.iconFont,
    fontPackage: CupertinoIcons.iconFontPackage,
  ),
),

Ref: Why are there so few icons in cupertino_icons?

ちなみに、公式のMaterial Iconも足りていない

Missing Material Icons...

これも結構不便。
ご丁寧にアップデート手順のREADMEまで用意されているが、 (Google-only, sorry)

6
3
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
6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?