1
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.

Dartのエラー "Error: Not a constant expression." の解決方法

Posted at

Dartのエラー "Error: Not a constant expression." が発生して、一瞬戸惑ったので、解決方法のメモです。

発生した状況

最初に、以下のようにListTileを追加し、

              const ListTile(
                title: Text('ログアウト'),
              ),
            ],

そこに「onTap」を追加すると、発生した。

              const ListTile(
                title: Text('ログアウト'),
                onTap: (){},
              ),

解決方法

ListTileにつけていた「const」を外す。
※関数を入れたことにより、定数ではなくなったため、エラーが発生したと思われる。

              ListTile(
                title: Text('ログアウト'),
                onTap: () {},
              ),
1
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
1
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?