如何实现从_ListItem 到assetPath 的字符串列表?
how to implement string list from _ListItem to assetPath?
我一直在使用壁纸应用程序。
我设法调用壁纸的路径列表,
我可以在图像卡列表上完成这项工作,但我无法设法与 WallpaperManager
的 assetPath 一起工作
求助,有什么办法吗?
Future<void> setWallpaperFromAsset() async {
setState(() {
_wallpaperAsset = "Loading";
});
String result;
String assetPath = ('Load List here');
您可以将参数 assetPath
添加到 setWallpaperFromAsset
Future<void> setWallpaperFromAsset(String assetPath) async {
setState(() {
_wallpaperAsset = "Loading";
});
String result;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
result = await WallpaperManager.setWallpaperFromAsset(
assetPath, WallpaperManager.HOME_SCREEN);
} on PlatformException {
result = 'Failed to get wallpaper.';
}
}
并且您注册 onPressed
回调:
RaisedButton.icon(
onPressed: () => setWallpaperFromAsset(item),
icon: Icon (Icons.wallpaper, size: 20),
label: Text('homescreen')),
)
我一直在使用壁纸应用程序。 我设法调用壁纸的路径列表, 我可以在图像卡列表上完成这项工作,但我无法设法与 WallpaperManager
的 assetPath 一起工作求助,有什么办法吗?
Future<void> setWallpaperFromAsset() async {
setState(() {
_wallpaperAsset = "Loading";
});
String result;
String assetPath = ('Load List here');
您可以将参数 assetPath
添加到 setWallpaperFromAsset
Future<void> setWallpaperFromAsset(String assetPath) async {
setState(() {
_wallpaperAsset = "Loading";
});
String result;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
result = await WallpaperManager.setWallpaperFromAsset(
assetPath, WallpaperManager.HOME_SCREEN);
} on PlatformException {
result = 'Failed to get wallpaper.';
}
}
并且您注册 onPressed
回调:
RaisedButton.icon(
onPressed: () => setWallpaperFromAsset(item),
icon: Icon (Icons.wallpaper, size: 20),
label: Text('homescreen')),
)