Hello, has anyone else experienced this nested sc...
# compose
j
Hello, has anyone else experienced this nested scrolling error when trying to persist scroll state?
java.lang.IllegalStateException: Nesting scrollable in the same direction layouts like ScrollableContainer and LazyColumn is not allowed.
I have a
LazyColumn
in a
Fragment
with a
LinearLayout
This all works fine until I attempt to add
.verticalScroll(rememberScrollState())
to the
LazyColumn
and I get the above error
a
why do you want to add verticalScroll on LazyColumn? LazyColumn is scrollable already
j
Maybe I misread the documentation but that is what was being done in the sample
Copy code
State of the scroll. Allows the developer to change the scroll position or get current state by calling methods on this object. To be hosted and passed to Modifier.verticalScroll or Modifier.horizontalScroll
I see now that they are doing this on a Column and not a LazyColumn which may be an issue
m
On Lazy collections you have to do it by passing scroll state as `state`parameter to the constructor, not via Modifier. But I'm interested how to add horizontal scrolling to the LazyColumn, which also produces the same error.
j
Actually it is not
ScrollState
it is
LazyListState
which is something else entirely 😢
Is it a bug with Compose that
scrollable()
is accessible in
LazyLists
then?
At a minimum it's definitely odd that it's a run time exception rather than compile time.
1