【Flutter】flutter-stydy.devのAdmin Mobileをやってみた

今回はflutter-study.devのAdmin Mobileというものを作成してみました。以下の記事のものです。

www.flutter-study.dev

 

基本的には書いてある通りですが、1点つまったところがあったので書いておきます。

 

詰まったところは以下の部分です。

const  _Postのところでkeyを使ってコンストラクタに渡しているのですが、デフォルトで値がnullになっているのにnullを渡そうとしてエラーが出てしまいます。

したがってkeyをoptional型で宣言する必要があります。

class _Post extends StatelessWidget {
  final String name;
  final String message;
  final String textReason;
  final Color colorPrimary;
  final Color colorPositive;
  final String textPositive;
  final Color colorNegative;
  final String textNegative;

  const _Post({
    Key key,
     this.name,
     this.message,
     this.textReason,
     this.colorPrimary,
     this.colorPositive,
     this.textPositive,
     this.colorNegative,
     this.textNegative,
  }) : super(key: key);

〜以下省略〜
}


エラーの内容と簡単な解決方法は以下の記事にまとめてあるのでみてみてください。

moun45.hatenablog.com

 

 

【完成画面のスクリーンショット

f:id:moun45:20220322130744p:plain