I updated my project from dev03 to dev04 and get t...
# compose
a
I updated my project from dev03 to dev04 and get this error.
java.lang.ClassCastException: androidx.compose.GroupStart cannot be cast to androidx.ui.foundation.ScrollerPosition
It was working fine in dev03. Can anyone help me to resolve this error and why this is occuring ??
i
not had this one yet, did it link to where in the code its failing? did you update the dependencies with new compiler etc?
a
And, I believe that, I have updated dependencies with new compiler.
i
cool I had a look but can't see anything I am familiar with ๐Ÿ˜ž
a
i
cool, is that with
dev04
because I think +MaterialTheme is no longer needed
Copy code
MaterialTheme.colors().surface
can be this now
a
Yes, That code is in dev03
Copy code
var internationalState = observer(newArticleModel.internationalHeadline)
Surface(color = (MaterialTheme.colors()).surface, modifier = LayoutSize.Fill) {
    if (internationalState == null) {
        ShowLoading()
    } else if (internationalState.isEmpty()) {
        NoContentMore()
    } else {
        val scrollerPosition: ScrollerPosition = remember { ScrollerPosition(0f) }
        println("MainActivity data here : " + internationalState)

        Observe {
            onCommit(scrollerPosition.isAtEndOfList) {
                println("Is commit entered")
                if(scrollerPosition.isAtEndOfList)
                    newArticleModel.loadMoreData()
            }
        }
        VerticalScroller(scrollerPosition = scrollerPosition) {
            Column(modifier = LayoutSize.Fill) {
                println("Page rendering size " + PageSize.topHeadlineInternationalPageNo)
                internationalState!!.forEach {
                    Ripple(bounded = true) {
                        Clickable() {
                            ArticleTicket(
                                backgroundColor = (MaterialTheme.colors()).background,
                                article = it
                            )
                        }
                    }

                }
            }
        }
    }
}
Dev04 code
i
aha I see but are you using
dev04
now in your project?
cool
did you add this?
Copy code
composeOptions {
        kotlinCompilerExtensionVersion "$compose_version"
    }
to your gradle files?
a
Yes
i
awesome
seems the error complains about this line
val scrollerPosition: ScrollerPosition = remember { ScrollerPosition(0f) }
a
I think so But don't know what is going wrong
m
ScrollerPosition() is a composable function now that does memorization for you
โ˜๏ธ 1
Just remove outer remember and it will work ๐Ÿ™‚
i
nice ๐Ÿ˜„
m
Copy code
remember {
    remember {
    }
}
a
Matvei beat me to it. ๐Ÿ™‚ We're not correctly detecting that you're trying to make a composable call in the non-composable body of remember there. Ideally fixed in the next release
m
This won't work and should ideally be a compiler error or a warning
a
The reason for the change is that ScrollerPosition reads the current density ambient so that it can use the native android fling motion now
๐Ÿ‘ 2
a
nice, It is working now
๐Ÿ™ 1
๐Ÿ‘ 1