Last active
May 30, 2023 20:51
-
-
Save saqib-github-commits/b1cc041bd63c0c3a328eb819c3a4764b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun ScrollToTopDerivedAndRememberedCase(lazyListState: LazyListState) { | |
val isEnabledDerivedStateCase by remember { derivedStateOf { lazyListState.firstVisibleItemIndex > 0 }} | |
val isEnabledRememberCase = remember(lazyListState.firstVisibleItemIndex) { lazyListState.firstVisibleItemIndex > 0} | |
Column( | |
modifier = Modifier.fillMaxSize(), | |
verticalArrangement = Arrangement.Bottom, | |
horizontalAlignment = Alignment.CenterHorizontally | |
) { | |
Button(onClick = { /*TODO*/ }, enabled = isEnabledDerivedStateCase) { | |
Text(text = "Derived State Button") | |
} | |
Button(onClick = { /*TODO*/ }, enabled = isEnabledRememberCase) { | |
Text(text = "Remembered Button") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment