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

What does "Expecting member declaration" mean?

I am creating this class as part of a tutorial for Compose navigation.

sealed class Screens(val route: String) {
    object Screen1 : Screens( route: "screen1")
    object Screen2 : Screens( route: "screen2")
}

I am getting the error "Expecting member declaration". What does this error mean in simple terms?

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

>Solution :

It should either be Screens("screen1") or (if you want to use named arguments) Screens(route="screen1"), with a =.

That error is because the syntax you’re using (with the colon) is confusing the compiler, it doesn’t make sense there

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