I'm new to Kotlin and I'm following a Room tutorial but (at about 32 minutes) I get an error that I wasn't able to fix:
This is my code:
@Composable
fun ContactScreen(
state: ContactState,
onEvent: (ContactEvent) -> Unit
){
Scaffold(
floatingActionButton = {
FloatingActionButton(onClick ={
onEvent(ContactEvent.ShowDialog)
}){
Icon(imageVector = Icons.Default.Add, contentDescription = "Add contact")
}
}
){padding ->
LazyColumn (
contentPadding = padding,
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(16.dp)
){
}
}
}
these are my imports:
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.Icon
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.google.android.material.floatingactionbutton.FloatingActionButton
This is the screenshot of the video (I checked every comma and parenthesis)
The solution is in the comment:
You have the wrong FloatingActionButton
imported. It should be androidx.compose.material3.FloatingActionButton
. –
Mike M.
Thanks to Mike