Created
October 23, 2023 13:17
-
-
Save jershell/991bf5ee498ebee2b234afca457d2bbe to your computer and use it in GitHub Desktop.
Cargo11.kt
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
package cargo | |
import androidx.compose.foundation.layout.Column | |
import androidx.compose.foundation.layout.fillMaxWidth | |
import androidx.compose.material.Text | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Modifier | |
// Exception in thread "main" java.lang.NullPointerException: Parameter specified as non-null is null: | |
// method cargo.ComponentScopeImpl.Child, parameter modifier | |
@Composable | |
fun Cargo11() { | |
RootComponent() { | |
Child(item = "aaa") | |
Child(item = "bbb") | |
Child(item = "ccc") | |
} | |
} | |
abstract class ComponentScope() { | |
@Composable | |
open fun Child(modifier: Modifier = Modifier.fillMaxWidth(), item: String) {} | |
} | |
private object ComponentScopeImpl : ComponentScope() { | |
@Composable | |
override fun Child(modifier: Modifier, item: String) { | |
Column(modifier) { | |
Text(item) | |
} | |
} | |
} | |
@Composable | |
fun RootComponent(content: @Composable ComponentScope.() -> Unit) { | |
ComponentScopeImpl.content() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment