搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.10

wallpaper_manager

一個用於在 Android 設備上變更主螢幕、鎖定畫面(或兩者)壁紙的 Flutter 外掛程式。

近 30 天下載
83
喜歡數
103
Pub 分數
40

安裝套件

flutter pub add wallpaper_manager

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Wallpaper Manager 是一個 Flutter 插件,可讓開發者透過程式設計方式在 Android 設備上設定主畫面、鎖定畫面或兩者同時的壁紙。它提供簡單的介面,允許直接從 Flutter 應用中將圖片套用為壁紙,進而提升照片或自訂應用的使用者體驗。此插件利用原生 Android API,目前僅支援 Android,沒有 iOS 實作。它需要適當的權限,並在專注於個人化、影像相簿或數位藝術展示的應用中整合時效果最佳。

適用情境

  • 從應用內容設定動態壁紙
  • 建立具壁紙功能的照片相簿應用
  • 在生活風格應用中啟用使用者自訂
  • 在數位藝術平台中整合壁紙變更

主要特色

  • 設定主畫面壁紙
  • 設定鎖屏壁紙
  • 同時支援兩個螢幕
  • 與 Flutter 的簡單 API 集成
  • 使用原生 Android 壁紙 API

適合對象

  • 僅限 Android 的應用需要變更壁紙
  • 照片和藝術分享應用
  • 使用者個人化工具
  • 具有動態背景主題的應用程式

使用建議

  • 僅適用於安卓設備
  • 需要執行時權限請求
  • 受限於 Android 的壁紙系統
  • 不支援 iOS
  • 可能需要處理圖像解析度和格式

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

wallpaper_manager

Wallpaper Manager

A Flutter plugin for changing the Home Screen, Lock Screen (or both) Wallpaper(s) on Android devices.

Pub

Usage

Installation

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  wallpaper_manager: "^1.0.10"

In your library add the following import:

import 'package:wallpaper_manager/wallpaper_manager.dart';
Example
Basic Usage

Since this is not a Widget, you have to create WallpaperManager constructors from inside an async function, which is a Future that returns a String output specifying success/failure.

String path = "/path/to/file/on/disk";
int location = WallpaperManager.HOME_SCREEN; // or location = WallpaperManager.LOCK_SCREEN;
final String result = await WallpaperManager.setWallpaperFromFile(path, location);
Basic Usage with error handling

You might want to wrap it in a try/catch since platform messages (plug-ins like these) may fail

String path = "/path/to/file/on/disk";
int location = WallpaperManager.HOME_SCREEN; // or location = WallpaperManager.LOCK_SCREEN;
String result;
try {
  result = await WallpaperManager.setWallpaperFromFile(path, location);
} on PlatformException {
  result = 'Failed to get wallpaper.';
}
Loading from a URL (with CacheManager, the image is saved to app files as well)

If you're loading a Wallpaper from a URL, you should save it to the disk first, then use the path of the saved image file. Add flutter_cache_manager or any other dependency you'd like:

dependencies:
  ...
  flutter_cache_manager: "^1.1.3"

And in dart code

String url = "";
int location = WallpaperManager.HOME_SCREEN; // or location = WallpaperManager.LOCK_SCREEN;
String result;
var file = await DefaultCacheManager().getSingleFile(url);
final String result = await WallpaperManager.setWallpaperFromFile(file.path, location);
Loading from a Flutter asset

If you're loading a Wallpaper from an asset, you need to make sure it is indexed in the pubspec.yaml file first

dependencies:
  ...
  flutter:
    ...
    assets:
    - assets/tmp1.jpeg

And in dart code

String assetPath = "assets/tmp1.jpg";
int location = WallpaperManager.HOME_SCREEN; // or location = WallpaperManager.LOCK_SCREEN;
String result;
final String result = await WallpaperManager.setWallpaperFromAsset(assetPath, location);

Getting started

With Wallpaper Manager

See the example directory for a complete sample app using Wallpaper Manager.

With Flutter

For help getting started with Flutter, view the online documentation.

Notes

  • iOS does not support changing Wallpapers from third-party apps (Source)
  • Xiaomi/MIUI does not support changing Lock Screen Wallpapers directly from the Android API (Source). You might want to look at creating a Lock Screen Launcher app instead.

Known Issues

Todos

  • [ ] Write tests
  • [x] Add rect values for optionally cropping the image
  • [ ] Add variable for re-using Wallpaper from phone's settings
  • [ ] Write more tests

Changelog

Please see the Changelog page to know what's recently changed.

Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a feature, please send a pull request.

所屬分類

原始碼儲存庫

使用此套件的專案