Reputation: 131
I am using async_wallpaper package and this is the function
Future<void> setLiveWallpaper(String liveUrl) async {
setState(() {
_liveWallpaper = 'Loading';
});
String result;
var file = await DefaultCacheManager().getSingleFile(liveUrl);
try {
result = await AsyncWallpaper.setLiveWallpaper(
filePath: file.path,
goToHome: true,//tried false also
toastDetails: ToastDetails.success(),
errorToastDetails: ToastDetails.error(),
)
? 'Live Wallpaper set'
: 'Failed to set live wallpaper.';
} on PlatformException catch (e) {
print('PlatformException>>>>>>>>>>>>>.: $e');
result = 'Failed to set live wallpaper.';
}
if (!mounted) return;
setState(() {
_liveWallpaper = result;
});
}
this is where i dispaly the live wallpapers thumbnails
After Click one of the wallpaper it shows the wallpaper preview
Upvotes: 0
Views: 232
Reputation: 1
you can set SystemNavigator.pop in this function to close the app after applying the wallpaper. this will be a good approach for the user because in almost every app this method is used where when the user applies the wallpaper then the app closed and the wallpaper shows to the user.
Upvotes: 0