Why can't I use `AnimatedVisibility` in a `BoxScope`?

73
June 15, 2021, at 5:50 PM

I have a layout which looks like this:

Row {
        ...
        Box(
            modifier = Modifier
                .fillMaxHeight()
                .width(50.dp)
        ) {
            AnimatedVisibility(
                visible = isSelected && selectedAnimationFinished,
                enter = fadeIn(),
                exit = fadeOut()
            ) {
                ...
            }
        }
    }

But I get the compile-time error:

fun RowScope.AnimatedVisibility(visible: Boolean, modifier: Modifier = ..., enter: EnterTransition = ..., exit: ExitTransition = ..., content: AnimatedVisibilityScope.() -> Unit): Unit' can't be called in this context by implicit receiver. Use the explicit one if necessary

It appears that Kotlin finds the AnimatedVisibility function ambiguous, since Compose exposes multiple AnimatedVisibility functions with the same signature: there's a fun AnimatedVisibility with no receiver, and a fun RowScope.AnimatedVisibility which requires RowScope.

From what I can gather, Kotlin is complaining about me using the RowScope version incorrectly, but I just want to use the version with no receiver!

Using this.AnimatedVisibility also doesn't help.

The only workaround I've found that works is to fully qualify the name, like androidx.compose.animation.AnimatedVisibility(...). But I have no idea why this works.

Can anyone shed some like on this? Is there a better option I can use than fully qualifying the name?

READ ALSO
Compare Elements from Two Dataframe Lists

Compare Elements from Two Dataframe Lists

I need to compare two lists, each from a different data frameIt should be: if element in List 3 is not in List 1 AND element in List 5 is not in List 1 AND element in List 4 IS in List 2, then print the elements in List 3

60
Can sonarlint be used in place of checkstyle?

Can sonarlint be used in place of checkstyle?

I am working on a project which already has sonarqube integratedNow, we want to have a plugin in our local IDE(with some sort of XML) so that everyone in the team can have the same set of rules

62
subdomain routing | DNS ZONE | CNAME Record

subdomain routing | DNS ZONE | CNAME Record

Helo! I hope I asked the right question in the title

30
Apply jQuery before add to cart action in woo-commerce word press

Apply jQuery before add to cart action in woo-commerce word press

I need a confirmation popup before user proceed to add to cartIf user click to yes in confirmation box then should add product to cart and redirect to cart page as what happens in normal flow, in woo commerce wordpress

64