【Flutter】「The method ‘RaisedButton’ isn’t defined for the type」の原因と対策

Flutterのエラー「The method ‘RaisedButton’ isn’t defined for the type」の原因と対策について紹介します。

スポンサーリンク

「The method ‘RaisedButton’ isn’t defined for the type」の原因と対策

Flutterでデバッグすると以下のエラーが出ました。

The method 'RaisedButton' isn't defined for the type 'TodoDetailState'. (Documentation)  Try correcting the name to the name of an existing method, or defining a method named 'RaisedButton'.

Flutterの新バージョンで「RaisedButton」が廃止になったことが原因でした。
代わりに「ElevatedButton」を使用することでエラーが解消されました。

修正前

RaisedButton(
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(10.0)),
    padding: EdgeInsets.all(13.0),
(略)

修正後

ElevatedButton(
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(10.0)),
    padding: EdgeInsets.all(13.0),
(略)
スポンサーリンク

関連ページ

【Flutter入門】iOS、Android、Windowsアプリ開発
FlutterによるiOS、Android、Windowsアプリ開発について入門者向けに紹介します。
flutter
スポンサーリンク

コメント