概要
掲題の件の実現に詰まり、下記のようなエラーと遭遇した。
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during performResize():
Vertical viewport was given unbounded height.
Viewports expand in the scrolling direction to fill their container. In this case, a vertical
viewport was given an unlimited amount of vertical space in which to expand. This situation
typically happens when a scrollable widget is nested inside another scrollable widget.
If this widget is always nested in a scrollable widget there is no need to use a viewport because
there will always be enough vertical space for the children. In this case, consider using a Column
instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
the height of the viewport to the sum of the heights of its children.
と怒られる。。。
原因
SingleChildScrollViewとListView共に表示スペースを最大限まで取得しようとして、いたちごっこになっているせいなのかな?
解決策
下記のようにshrinkWrapとphysicsを追加することで解決した。
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap
スクロールビューの範囲を、表示中のコンテンツによって決定するかどうかを指定するプロパティ。デフォルトはfalseであり、この場合はスクロールビューはスクロール軸において許容される最大サイズまで拡大される。
trueを明示することで、ListViewは必要最低限の表示スペースを取得する。
physics
スクロール方法を設定できるプロパティ。
NeverScrollableScrollPhysicsを設定するとスクロールができないようになる。