@Composable
fun MainScreen() {
Scaffold(topBar = { AppBar() } ) {
Surface(modifier = Modifier
.fillMaxSize()
.padding(it)) {
Column() {
ProfileCard()
}
}
}
}
@Composable
fun AppBar(){
TopAppBar(
title = { Text(text = "Hi")}
) {}
}
I'm getting 2 error
@Composable invocations can only happen from the context of a @Composable function
None of the following functions can be called with the arguments supplied.
I'm trying to add a TopAppBar but if i give a composable for title or navigationIcon I get this error
CodePudding user response:
it should be
@Composable
fun AppBar(){
TopAppBar( title = { Text("Hi")},)
}