Flutterで入力フォームを作っているときに横並びのTextFormFieldを作成したい場合があります
通常、Widgetを横並びにする場合Rowのchildrenにします
例えばRaisedButtonを横並びにする場合は下記のようになります
Row( children: [ RaisedButton(child: Text('button1')), RaisedButton(child: Text('button2')) ] )
これは問題なく動作しますが、TextFormFieldで同じことをしようとするとエラーになります
Row( children: [ TextFormField(), TextFormField() ] )
エラーメッセージを見ると下記のようになっています
RenderBox was not laid out: RenderLeaderLayer#80f05 NEEDS-LAYOUT NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1785 pos 12: 'hasSize'
解決策としてはTextFormFieldをFlexibleのchildにすればOKです
Row( children: [ Flexible(child: TextFormField()), Flexible(child: TextFormField()) ] )