Q1 :- what is Box
Ans : -> Its like a a framLayout
Q2 :- what is FillMaxSize
Ans :- To cover whole height and width.
Q 3:- what is Clip Modifier
It is used to to pass the custom safe for view.
Q 4:- What is Produce State ?
Produce state is upadate the object asynchronous and give the object .
its utility function of jetpack compose.
Example :-
@Composable
fun StateProducerExample() {
var counter by produceState(initialValue = 0) {
// This block is executed in a coroutine
while (true) {
delay(1000) // Simulate some asynchronous work
counter++ // Update the counter
}
}
Column {
Text("Counter value: $counter")
}
}
Q 5:- What is derivedState State ?
if you have multiple state object you want to make another new state object using
both . on that you can use derivedStateOf .
Example :-
@Composable
fun DerivedStateOfExample() { var name by remember { mutableStateOf("John") } var age by remember { mutableStateOf(25) } // Using derivedStateOf to create a derived state based on name and age val formattedText by derivedStateOf { "Name: $name, Age: $age" } Column { // UI elements using the derived state Text("Formatted Text: $formattedText") // UI elements for updating the base states TextField(value = name, onValueChange = { name = it }, label = { Text("Name") }) TextField(value = age.toString(), onValueChange = { age = it.toIntOrNull() ?: 0 }, label = { Text("Age") }) } }
No comments:
Post a Comment