下記のようなエラーはどのように解決すればよろしいですか?
おそらくレイアウトに関するエラーだと思います。
ListTileをコメントアウトすればうまいく行きます。
なぜ、ListTileをつけるとエラーになるのでしょうか?
RenderBox was not laid out: RenderPadding#8a81a NEEDS-LAYOUT NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1930 pos 12: 'hasSize'
Dart
1override 2 Widget build(BuildContext context) { 3 final _chatRoom = ChatRoom(doc: widget.snap.data()); 4 _chatRoom.documentId = widget.snap.id; 5 6 DateTime _datetime = _chatRoom.createdAt.toDate(); 7 var _formatter = DateFormat("M/d HH:mm"); 8 String postDate = _formatter.format(_datetime); 9 10 bool _imageActive = false; 11 double _height = 75; 12 13 if (_chatRoom.messageImageUrl != "") { 14 _imageActive = true; 15 _height = 300; 16 } 17 18 final uid = FirebaseAuth.instance.currentUser.uid; 19 20 return FutureBuilder( 21 future: getUserInfoFromFirestore(uid: _chatRoom.uid), 22 builder: (BuildContext context, AsyncSnapshot<UserInfomation> snapshot) { 23 if (snapshot.connectionState != ConnectionState.done) { 24 return const SizedBox( 25 height: 0.8, child: const LinearProgressIndicator()); 26 } 27 return Padding( 28 padding: const EdgeInsets.symmetric(horizontal: 5.0, vertical: 9.0), 29 child: Container( 30 height: 400, 31 decoration: BoxDecoration( 32 border: Border.all(color: Colors.grey), 33 borderRadius: BorderRadius.circular(8.0), 34 ), 35 child: Column( 36 children: <Widget>[ 37 ListTile( 38 leading: Container( 39 width: 50, 40 height: 50, 41 clipBehavior: Clip.antiAlias, 42 decoration: BoxDecoration( 43 shape: BoxShape.circle, color: Colors.black38), 44 child: Image.network( 45 snapshot.data.image_url, 46 fit: BoxFit.cover, 47 ), 48 ), 49 trailing: Text( 50 postDate, 51 style: TextStyle(fontSize: 12, color: Colors.black38), 52 ), 53 title: Container( 54 // color: Colors.blue, 55 child: Text(snapshot.data.username), 56 ), 57 subtitle: Text( 58 snapshot.data.department + " " + snapshot.data.subject, 59 style: TextStyle( 60 fontSize: 10, 61 ), 62 ), 63 onTap: () { 64 Navigator.push( 65 context, 66 MaterialPageRoute( 67 builder: (context) => UserDetailPage( 68 uid: _chatRoom.uid, 69 userName: snapshot.data.username), 70 ), 71 ); 72 }, 73 ), 74 GestureDetector( 75 onTap: () { 76 Navigator.push( 77 context, 78 MaterialPageRoute( 79 builder: (context) => 80 DetailMessage(_chatRoom.documentId), 81 ), 82 ); 83 }, 84 child: Column( 85 children: [ 86 Container( 87 height: 40, 88 width: 100, 89 color: Colors.blue, 90 alignment: Alignment.topLeft, 91 child: Text( 92 _chatRoom.message, 93 style: TextStyle(fontSize: 14), 94 ), 95 ), 96 (_imageActive) 97 ? Container( 98 height: 220, 99 clipBehavior: Clip.none, 100 child: Image.network( 101 _chatRoom.messageImageUrl, 102 fit: BoxFit.cover, 103 ), 104 ) 105 : Container(), 106 Container( 107 height: 35, 108 child: Row( 109 mainAxisAlignment: MainAxisAlignment.spaceBetween, 110 children: [ 111 SizedBox( 112 width: 80, 113 ), 114 Container( 115 child: Row( 116 mainAxisAlignment: MainAxisAlignment.center, 117 children: [ 118 const Icon( 119 Icons.comment_outlined, 120 size: 20, 121 color: Colors.black38, 122 ), 123 Text( 124 " " + _chatRoom.relyNum.toString(), 125 style: TextStyle( 126 fontSize: 13, 127 color: Colors.black38, 128 ), 129 ), 130 ], 131 ), 132 ), 133 Consumer<LikeModel>( 134 builder: (context, model, child) { 135 return StreamBuilder<QuerySnapshot>( 136 stream: FirebaseFirestore.instance 137 .collection("messages") 138 .doc(_chatRoom.documentId) 139 .collection("favorite") 140 .snapshots(), 141 builder: (context, snapshot) { 142 if (!snapshot.hasData) return Container(); 143 144 List<dynamic> array = 145 snapshot.data.docs[0]["favoriteNum"]; 146 147 if (array.contains(uid)) { 148 model.buttonColor = Colors.pink[300]; 149 } else { 150 model.buttonColor = Colors.black38; 151 } 152 153 return Container( 154 width: 57, 155 child: IconButton( 156 onPressed: () { 157 model.chageColor( 158 chatId: _chatRoom.documentId, 159 snap: snapshot.data.docs[0]); 160 }, 161 icon: Row( 162 mainAxisAlignment: 163 MainAxisAlignment.center, 164 children: [ 165 Icon( 166 Icons.favorite, 167 color: model.buttonColor, 168 size: 20, 169 ), 170 Text( 171 " " + 172 snapshot.data.docs[0] 173 .data()["favoriteNum"] 174 .length 175 .toString(), 176 style: TextStyle( 177 fontSize: 13, 178 color: Colors.black38, 179 ), 180 ), 181 ], 182 ), 183 ), 184 ); 185 }); 186 }, 187 ) 188 ], 189 ), 190 ) 191 ], 192 ), 193 ), 194 ], 195 ), 196 ), 197 ); 198 }, 199 ); 200 } 201
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。