如何在 Jetpack Compose 中预览 LazyPagingItems/Paging 3 库

时间:2021-07-29 06:48:27

标签: android-jetpack-compose android-jetpack-compose-list

我认为标题说明了一切。

LazyPagingItems 构造函数是内部的。我无法在 Preview Composable 中将 LazyPagingItems 作为参数传递,更不用说传递示例数据了。但是我想显示我的可组合预览,我该怎么做?

@Composable
fun MainUi(users: LazyPagingItems<User>) {
    Scaffold {
        LazyColumn() {
            items(users) {
                // Rest of the code..
            }
        }
    }
}

@Preview
@Composable
fun Preview() {
    DefaultTheme {
        MainUi(users = ) // How to pass sample data here?
    }
}

0 个答案:

没有答案