Search code examples
androidkotlinandroid-jetpack-composepagerjetpack-compose-accompanist

Unresolved reference: pagerTabIndicatorOffset


I'm pretty new to jetpack and am following this guide.

When trying to create my tabs I'm hitting an UnresolvedReference and I'm not sure why

@ExperimentalPagerApi
@ExperimentalMaterialApi
@Composable
fun Tabs(tabs: List<TabItem>, pagerState: PagerState) {
    val scope = rememberCoroutineScope()
    TabRow(
        selectedTabIndex = pagerState.currentPage,
        backgroundColor = colorResource(id = R.color.colorPrimaryDark),
        contentColor = Color.White,
        indicator = { tabPositions ->
            TabRowDefaults.Indicator(
                Modifier.pagerTabIndicatorOffset(pagerState, tabPositions)
            )
        }) {
        tabs.forEachIndexed { index, tab ->
            LeadingIconTab(
                selected = pagerState.currentPage == index,
                text = { Text(tab.title) },
                icon = { Icon(painter = painterResource(id = tab.icon), contentDescription = "") },
                onClick = {
                    scope.launch {
                        pagerState.animateScrollToPage(index)
                    }
                },
            )
        }
    }

Everything else work. I have implementation("com.google.accompanist:accompanist-pager:0.28.0") in my build.gradle and am importing

Did I miss an import or library somewhere? androidx.compose.ui.Modifier in the class itself. I know I saw elsewhere that was a common Modifier problem.


Solution

  • Its a separate one that you have to specify in your dependencies.

    implementation 'com.google.accompanist:accompanist-pager-indicators:0.27.1'
    

    I removed mine and same error shown enter image description here