Reputation: 2255
I use Jetpack Compose in a Android Studio project, the code A can work well, but I get the following warning information, why ?
"Modifier parameter should be named modifier"
Code A
@Composable
fun ScreenAbout(
rootModifier: Modifier = Modifier,
onBack: () -> Unit,
scaffoldState: ScaffoldState = rememberScaffoldState()
) {
Scaffold(
modifier = rootModifier.fillMaxSize(),
scaffoldState = scaffoldState,
topBar = { AboutAppBar(onBack = onBack) }
) { paddingValues ->
Column(
...
}
Upvotes: 3
Views: 2637
Reputation: 363737
There is the code to Lint Check.
It checks Composable functions with Modifiers parameters for consistency with guidelines.
For functions with one / more modifier parameters, the first modifier parameter must:
modifier
Modifier
Modifier
In you case just use:
@Composable
fun ScreenAbout(
modifier: Modifier = Modifier,
Or if you want to suppress the warning add
@SuppressLint("ModifierParameter")
@Composable
fun ScreenAbout(
rootModifier: Modifier = Modifier,
Upvotes: 3