WallpaperManagerFlutter 是一个 Flutter 插件,可在 Android 设备上设置主屏幕、锁屏或两者同时的壁纸。它能高效处理大图像并实现快速性能,非常适合需要动态更换壁纸的应用程序。该插件可无缝集成到 Flutter 项目中,并提供简单直观的 API 来编程管理壁纸设置。对于旨在通过个性化背景提升用户体验的照片分享、个性化或生活方式类应用尤其有用。
适合场景
从应用内容设置自定义壁纸
创建带有壁纸功能的相册应用
启用用户驱动的主页个性化
开发具有视觉主题的生活方式或生产力应用程序
在图像编辑工具中集成壁纸功能
主要特点
支持主屏幕和锁屏壁纸设置
针对大图像处理进行了优化
快速高效的性能
与 Flutter 项目的简单集成
Android上的跨平台兼容性
适合对象
专注于 Android 的 Flutter 开发人员
需要动态壁纸更新的应用
照片和设计导向的应用程序
用户界面自定义工具
创意和生活方式移动应用
使用建议
仅限 Android 平台
需要适当的权限
可能具有设备特定的行为差异
与 iOS 不兼容
依赖于 Android 系统级别的壁纸 API
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Wallpaper Manager Flutter 🖼️
A powerful Flutter plugin that enables you to programmatically set wallpapers. This plugin maintains smooth performance even with high-resolution wallpapers. Easily customize home screen, lock screen, or both screens with just a few lines of code!
Features ✨
Set wallpapers on home screen, lock screen, or both 🏠
Efficient image processing using isolates to prevent UI blocking 🚀
Handles large image files without lag or freezing 💪
Comprehensive error handling and validation ✅
Simple and intuitive API 🎯
Demo 📱
A simple demonstration of setting wallpapers without any lag or freezing
You can set wallpapers for different screens using the following constants:
// Create instancefinal wallpaperManager = WallpaperManagerFlutter();
// Available options for wallpaper location: homeScreen, lockScreen & bothScreens// Example: Set wallpaper on home screentry {
File imageFile = File('path_to_your_image.jpg');
bool result = await wallpaperManager.setWallpaper(
imageFile,
WallpaperManagerFlutter.homeScreen,
);
if (result) {
print('Wallpaper set successfully! 🎉');
}
} catch (e) {
print('Error setting wallpaper: $e ❌');
}
Error Handling 🛡️
The plugin includes comprehensive error handling. Here are some common errors you might encounter:
File does not exist
Invalid location value
Platform-specific errors
Always wrap the setWallpaper call in a try-catch block to handle potential errors gracefully.
Platform Support 📱
Platform
Support
Notes
Android
✅
Full support for home screen, lock screen, and both screens
iOS
❌
Not supported due to iOS system security restrictions.
Note: Requires Android 7.0 (API level 24) or higher.
Contributing 🤝
Contributions are welcome! If you have a bug fix or new feature, please create a pull request. For major changes, please open an issue first to discuss what you would like to change.
License 📄
This project is licensed under the MIT License - see the LICENSE file for details.
Support ❤️
If you find this plugin helpful, please give it a star ⭐ on GitHub and consider following me for more useful Flutter plugins!
For any issues, feature requests, or questions, please create an issue on GitHub.