【Flutter】「The method ‘showSnackBar’ isn’t defined for the type ‘ScaffoldState’. 」の意味と対策

Flutterのエラー「The method ‘showSnackBar’ isn’t defined for the type ‘ScaffoldState’. 」の意味と対策について紹介します。

「The method ‘showSnackBar’ isn’t defined for the type ‘ScaffoldState’. 」の意味

Flutterでデバッグすると以下のようなエラーが出ることがあります。

The method 'showSnackBar' isn't defined for the type 'ScaffoldState'. (Documentation)  Try correcting the name to the name of an existing method, or defining a method named 'showSnackBar'
                Scaffold.of(context).showSnackBar(SnackBar(
                  content: Text("$title を削除"),
                ));
【Flutter入門】iOS、Android、Windowsアプリ開発
FlutterによるiOS、Android、Windowsアプリ開発について入門者向けに紹介します。

コメント