1
@Composable
fun toolbar() {
    Scaffold(
        topBar = {
            TopAppBar(
                title = {
                    Row(
                        modifier = Modifier.fillMaxWidth(),
                        horizontalArrangement = Arrangement.Center,
                        verticalAlignment = Alignment.CenterVertically
                    ) {
                        Button(
                            onClick = { /\*TODO\*/ },
                            modifier = Modifier.weight(3f),
                            colors = ButtonDefaults.buttonColors(backgroundColor = Color.White)
                        ) {
                            Icon(
                                imageVector = Icons.Filled.LocationOn,
                                contentDescription = null,
                                tint = Color.Black
                            )
                            Text(
                                text = "city name",
                                color = Color.Black
                            )
                            Icon(
                                painter = painterResource(id = R.drawable.arrow_down),
                                contentDescription = null,
                                tint = Color.Black
                            )
                        }
                        Spacer(modifier = Modifier.weight(1f))
                    }
                }, navigationIcon = {
                    IconButton(onClick = { /\*TODO\*/ }) {
                        Icon(imageVector = Icons.Filled.Menu, contentDescription = null)
                    }
                }, backgroundColor = Color.White
            )
        }) {
        Box(
            modifier = Modifier
                .padding(it)
                .fillMaxHeight()

        ) {

Row(modifier = Modifier.weight(1f)) {

}
         }
    }
}

Here in row whenever I am using weight modifier its showing error

Cannot access 'RowScopeInstance': it is internal in 'androidx.compose.foundation.layout'

even in box or column it doesn't work in my any project how to fix this error I am beginner so please help in most easy words

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • I think this [issue](https://stackoverflow.com/questions/74001640/cannot-access-rowscopeinstance-it-is-internal-in-androidx-compose-foundation) can resolve your problem Tushar – Mohan Raj May 29 '23 at 06:19

1 Answers1

0

You can't use the weight modifier in a BoxScope as in your code.

You can se the weight modifier in a RowScope or ColumnScope.

Row() {
   //RowScope
   Row(modifier = Modifier.weight(1f)) {

   }
}

Box() {
   //BoxScope
   
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841