Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How i can pass the icon in this compossable function ? So that i can reuse it

@Composable
fun LoginMethod(icon: Icon, text: String) {
    Row(
        modifier = Modifier
            .padding(8.dp)
            .shadow(
                elevation = 6.dp,
                shape = RoundedCornerShape(6.dp)
            )
    ) {
        Image(imageVector = icon, contentDescription ="")
        Spacer(modifier = Modifier.height(4.dp))
        Text(text = text)

    }
}
like image 877
Ashish Gautam Avatar asked Sep 07 '25 04:09

Ashish Gautam


1 Answers

You can use something like:

@Composable 
fun LoginMethod(icon: ImageVector, text : String) {

  /* your code */
}

and then call it with:

LoginMethod(  Icons.Filled.Add, "title" )
like image 91
Gabriele Mariotti Avatar answered Sep 09 '25 20:09

Gabriele Mariotti