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.