Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Modifier.fillMaxSize error unresolved reference error in jetpack compose

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

You need to import fillMaxSize like this it will work fine

import androidx.compose.foundation.layout.fillMaxSize
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading