Home > Mobile >  Modifier.fillMaxSize error unresolved reference error in jetpack compose
Modifier.fillMaxSize error unresolved reference error in jetpack compose

Time:10-20

I'm keep getting this error in jetpack compose. My error -

e: learn/app/src/main/java/com/learn/MainActivity.kt: (41, 32): Unresolved reference: fillMaxSize

My code

class MainActivity : ComponentActivity() {
    
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MaterialTheme{
                loginUI()
            }
        }
    }
}

@Composable
fun Greeting(){
   
    val image: Painter = painterResource(id = R.drawable.ic_launcher_background)
    Image(painter = image,contentDescription = "")
    Column(modifier = Modifier.fillMaxSize()){
        Text("Hello")
        Text("World")
    }
}

I have these imports

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.Text
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.Modifier
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import androidx.compose.foundation.layout.Column
import androidx.compose.material.MaterialTheme
import androidx.compose.foundation.Image
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource

These Dependencies

implementation 'androidx.core:core-ktx:1.9.0'
    implementation "androidx.compose.ui:ui:1.3.0-rc01"
    implementation "androidx.compose.material:material:1.3.0-rc01"
    implementation "androidx.compose.material3:material3:1.0.0-rc01"
    implementation "androidx.compose.material3:material3-window-size-class:1.0.0-rc01"
    implementation "androidx.compose.ui:ui-tooling-preview:1.3.0-rc01"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
    implementation 'androidx.activity:activity-compose:1.7.0-alpha01'
    implementation "androidx.navigation:navigation-compose:2.5.2"
    implementation "com.google.accompanist:accompanist-systemuicontroller:0.26.5-rc"
    
    //TESTS
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.2.1"
    debugImplementation "androidx.compose.ui:ui-tooling:1.3.0-rc01"

I watch tutorials from YouTube. And I am new to jetpack compose so I made this project to learn jetpack compose.

I use AndroidIDE. This one

Help to solve this

CodePudding user response:

You need to import fillMaxSize like this it will work fine

import androidx.compose.foundation.layout.fillMaxSize
  • Related