Backback arrow icon

The argument type &#8216;Iterable<Row>&#8216; can&#8217;t be assigned to the parameter type &#8216;List<Widget>&#8216;.

flutter始めたばかりで1時間ほどタイトルのエラーではまりました

とりあえず結論

// ダメ
Container(
  height: min(widget.order.products.length * 20.0 + 10, 180),
  child: ListView(
    children: widget.order.products.map((prod) => Row()),
  ),
),

// OK
// RowにtoList()メソッド入れる
Container(
  height: min(widget.order.products.length * 20.0 + 10, 180),
  child: ListView(
    children: widget.order.products.map((prod) => Row()).toList(), 
  ),
),

なぜ発生していたか?

Rowのchildrenには、通常<Widget>[]が入っており、Widget型のリストが期待されています。

しかしmapではRow だけ返していて、List型に変換されていないことが問題でした。

なので、最後にtoList() メソッドを入れてあげることで、<Widget>[] に適した型となり、エラーを吐き出さないようになります。

参考記事

toList method