File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
compose/snippets/src/main/java/com/example/compose/snippets/mentalmodel Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import androidx.compose.foundation.layout.Row
25
25
import androidx.compose.foundation.lazy.LazyColumn
26
26
import androidx.compose.foundation.lazy.items
27
27
import androidx.compose.material3.Button
28
+ import androidx.compose.material3.Card
28
29
import androidx.compose.material3.Checkbox
29
30
import androidx.compose.material3.HorizontalDivider
30
31
import androidx.compose.material3.MaterialTheme
@@ -108,15 +109,16 @@ fun ListComposable(myList: List<String>) {
108
109
109
110
// [START android_compose_thinking_in_compose_incorrect]
110
111
@Composable
111
- @Deprecated(" Example with bug" )
112
112
fun ListWithBug (myList : List <String >) {
113
113
var items = 0
114
114
115
115
Row (horizontalArrangement = Arrangement .SpaceBetween ) {
116
116
Column {
117
117
for (item in myList) {
118
- Text (" Item: $item " )
119
- items++ // Avoid! Side-effect of the column recomposing.
118
+ Card {
119
+ Text (" Item: $item " )
120
+ items++ // Avoid! Side-effect of the column recomposing.
121
+ }
120
122
}
121
123
}
122
124
Text (" Count: $items " )
You can’t perform that action at this time.
0 commit comments