フロント側をFlutter(スマホ)Thymeleaf(PC)、バックエンド側SpringBootの自動作成勉強中
13:00
①今日は『詳細、変更、削除ボタン』を作っている。
15:36
①Fluitter側『詳細、変更、削除ボタン』を追加したが、BottomNavigationBarItemの「リスト」アイコンをクリックすると、なんとバックエンドSpringBoot側サーバーがくるくるなんかエンドレスに処理始める。なんでだろう。
だめだめロジック。「 Row (」(『詳細、変更、削除ボタン』)をコメントにすると、昨日と同じなので普通に動く。
・・・多分、「 onPressed: httpForDetail(CommUtils.chgToString(element["id"])),」となっているけど、 onPressedしていないうちに、実際に「httpForDetail(CommUtils.chgToString(element["id"])),」が走っているみたいだ。「httpForDetail(String _id) {」を「void httpForDetail(String _id) {」にするとうまくいくのではと思ったが、
”This expression has a type of 'void' so its value can't be used. (ドキュメント) Try checking to see if you're using the correct API; there might be a function or call that returns void you didn't expect. Also check type parameters and variables which might also be void.”
↓Googleで翻訳
"この式のタイプは「void」であるため、その値は使用できません。 (ドキュメント)正しいAPIを使用しているかどうかを確認してみてください。 予期していなかったvoidを返す関数または呼び出しがある可能性があります。 また、無効である可能性のある型パラメーターと変数も確認してください。"
となる。
検索ボタン「void httpForListDo()」押下時はうまくいっている。詳細ボタン押下の処理は、多分パラメータ(「void httpForDetail(String _id) )が入っていてはダメなのだろう。・・・困ったな。→早め(17:28)に解決した。
// 一覧表を表示するWidgets List<Widget> _makeListWidgets() { ・・・ Row ( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( margin: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 5), padding: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 0), child: ElevatedButton( // 情報一覧リストへ、detail、httpアクセス onPressed: httpForDetail(CommUtils.chgToString(element["id"])), style: ElevatedButton.styleFrom( primary: Colors.blue, ), child: const Text("詳細"), ), ), Container( margin: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 5), padding: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 0), child: ElevatedButton( // 情報一覧リストへ、upd、httpアクセス onPressed: httpForUpd(CommUtils.chgToString(element["id"])), style: ElevatedButton.styleFrom( primary: Colors.blue, ), child: const Text("変更"), ), ), Container( margin: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 5), padding: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 0), child: ElevatedButton( // 情報一覧リストへ、del_do、httpアクセス onPressed: httpForDelDo(CommUtils.chgToString(element["id"])), style: ElevatedButton.styleFrom( primary: Colors.blue, ), child: const Text("削除"), ), ), ] ), ・・・ /// 情報一覧リストへ、detailで、httpアクセス httpForDetail(String _id) { httpForInfo("detail", "http://192.168.1.13:8080/members/admin/user/userA/detail", _id); } /// 情報一覧リストへ、updで、httpアクセス httpForUpd(String _id) { httpForInfo("upd", "http://192.168.1.13:8080/members/admin/user/userA/upd", _id); } /// 情報一覧リストへ、del_doで、httpアクセス httpForDelDo(String _id) { httpForInfo("del_do", "http://192.168.1.13:8080/members/admin/user/userA/del_do", _id); }
17:28
① 15:36の①Fluitter側『詳細、変更、削除ボタン』を追加したが、BottomNavigationBarItemの「リスト」アイコンをクリックすると、なんとバックエンドSpringBoot側サーバーがくるくるなんかエンドレスに処理始める。なんでだろう。のつづき。・・・自ロジックを、よくよく、見てみたら気づいた「 onPressed: (){}」にすればいけるんじゃないかと。「onPressed: httpForDetail(CommUtils.chgToString(element["id"])),」を「onPressed: (){httpForDetail(CommUtils.chgToString(element["id"]));},」に変えたら無事動いた。・・・よかった。
// 一覧表を表示するWidgets List<Widget> _makeListWidgets() { ・・・ Row ( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( margin: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 5), padding: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 0), child: ElevatedButton( // 情報一覧リストへ、detail、httpアクセス onPressed: (){httpForDetail(CommUtils.chgToString(element["id"]));}, style: ElevatedButton.styleFrom( primary: Colors.blue, ), child: const Text("詳細"), ), ), Container( margin: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 5), padding: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 0), child: ElevatedButton( // 情報一覧リストへ、upd、httpアクセス onPressed: (){httpForUpd(CommUtils.chgToString(element["id"]));}, style: ElevatedButton.styleFrom( primary: Colors.blue, ), child: const Text("変更"), ), ), Container( margin: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 5), padding: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 0), child: ElevatedButton( // 情報一覧リストへ、del_do、httpアクセス onPressed: (){httpForDelDo(CommUtils.chgToString(element["id"]));}, style: ElevatedButton.styleFrom( primary: Colors.blue, ), child: const Text("削除"), ), ), ] ), ・・・ /// 情報一覧リストへ、detailで、httpアクセス void httpForDetail(String _id) { httpForInfo("detail", "http://192.168.1.13:8080/members/admin/user/userA/detail", _id); } /// 情報一覧リストへ、updで、httpアクセス void httpForUpd(String _id) { httpForInfo("upd", "http://192.168.1.13:8080/members/admin/user/userA/upd", _id); } /// 情報一覧リストへ、del_doで、httpアクセス void httpForDelDo(String _id) { httpForInfo("del_do", "http://192.168.1.13:8080/members/admin/user/userA/del_do", _id); }
②まず、すでに登録画面を作成済みなのでこれを利用して更新画面を作ってみよう。