Repository: Automattic/pocket-casts-android
File: modules/features/profile/src/main/java/au/com/shiftyjelly/pocketcasts/profile/AccountDetailsPage.kt (Kotlin)

Code before:
            ) {
                item {
                    Spacer(
                        Modifier.height(
                            if (FeatureFlag.isEnabled(Feature.NEW_ONBOARDING_UPGRADE)) {
                                0.dp
                            } else {
                                16.dp
                            },
                        ),
                    )
                }
                item {
                    AccountHeader(
                        state = state.headerState,
                        config = headerConfig,
                        onClick = onClickHeader,
                        modifier = Modifier
                            .fillMaxWidth()
                            .padding(horizontal = 16.dp)
                            .then(if (state.isAutomotive) Modifier.padding(top = 32.dp) else Modifier),
                    )
                }

                item {
                    AnimatedVisibility(bannerState != null) {
                        when (bannerState) {
                            is ProfileUpgradeBannerState.OldProfileUpgradeBannerState -> {
                                Column(
                                    verticalArrangement = Arrangement.spacedBy(16.dp),
                                ) {
                                    Divider()
                                    ProfileUpgradeBanner(
                                        state = bannerState,
                                        onClickSubscribe = onClickSubscribe,
                                        onChangeFeatureCard = onChangeFeatureCard,
                                        modifier = Modifier.fillMaxWidth(),
                                    )
                                }
                            }

                            is ProfileUpgradeBannerState.NewOnboardingUpgradeState -> {
                                Box(modifier = Modifier.padding(horizontal = 24.dp)) {
                                    NewUpgradeAccountCard(
                                        onClickSubscribe = onAccountUpgradeClick,
                                        recommendedPlan = bannerState.recommendedSubscription,
                                    )
                                }
                            }

                            else -> Unit

Review comment (suggestion):
💡 We have `AnimatedNonNullVisibility` that you could use to avoid `null` in the content lambda.

Code after:
            ) {
                item {
                    Spacer(
                        Modifier.height(
                            if (FeatureFlag.isEnabled(Feature.NEW_ONBOARDING_UPGRADE)) {
                                0.dp
                            } else {
                                16.dp
                            },
                        ),
                    )
                }
                item {
                    AccountHeader(
                        state = state.headerState,
                        config = headerConfig,
                        onClick = onClickHeader,
                        modifier = Modifier
                            .fillMaxWidth()
                            .padding(horizontal = 16.dp)
                            .then(if (state.isAutomotive) Modifier.padding(top = 32.dp) else Modifier),
                    )
                }

                item {
                    AnimatedNonNullVisibility(bannerState) { bannerState ->
                        when (bannerState) {
                            is ProfileUpgradeBannerState.OldProfileUpgradeBannerState -> {
                                Column(
                                    verticalArrangement = Arrangement.spacedBy(16.dp),
                                ) {
                                    Divider()
                                    ProfileUpgradeBanner(
                                        state = bannerState,
                                        onClickSubscribe = onClickSubscribe,
                                        onChangeFeatureCard = onChangeFeatureCard,
                                        modifier = Modifier.fillMaxWidth(),
                                    )
                                }
                            }

                            is ProfileUpgradeBannerState.NewOnboardingUpgradeState -> {
                                Box(modifier = Modifier.padding(horizontal = 24.dp)) {
                                    NewUpgradeAccountCard(
                                        onClickSubscribe = onAccountUpgradeClick,
                                        recommendedPlan = bannerState.recommendedSubscription,
                                    )
                                }
                            }
                        }
                    }