I create a animation on jetpack compose. How can I create it in Flutter?
Jetpack compose code:
@Composable
fun Greeting( modifier: Modifier = Modifier) {
Column(
modifier = modifier.fillMaxSize()
) {
val isVisible = remember { mutableStateOf(true) }
Button(
onClick = {
isVisible.value = !isVisible.value
}
) {
Text(text = "Button")
}
AnimatedContent(
targetState = isVisible.value,
modifier = modifier
.fillMaxWidth()
.weight(1f),
content = {
if (it) {
Box(modifier = Modifier.background(Color.Red))
} else {
Box(modifier = Modifier.background(Color.Green))
}
},
transitionSpec = {
slideInHorizontally(
initialOffsetX = { if (isVisible.value) -it else it },
) togetherWith slideOutHorizontally(
targetOffsetX = { if (isVisible.value) it else -it },
)
},
label = "Animation"
)
}
}
I tried animated switcher but not worked like I expected.