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

套件詳情v3.7.0

async_wallpaper

在 Android 上非同步設定壁紙。也支援影片動態壁紙。

Android
近 30 天下載
2440
喜歡數
91
Pub 分數
160

安裝套件

flutter pub add async_wallpaper

套件介紹

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

一個 Flutter 套件,可於 Android 裝置上非同步設定壁紙,包含對影片動態壁紙的支援。它提供了一種簡單且高效的方式,讓您在 Flutter 應用中變更壁紙,而不會阻塞 UI 線程。此套件專為 Android 設計,並與原生 Android API 完全整合。它讓開發者能透過提供動態壁紙自訂選項,來提升使用者體驗。原始碼公開於 GitHub,以確保透明度與貢獻。

適用情境

  • 從應用程式設定靜態壁紙
  • 建立影片即時壁紙
  • 增強個人化功能
  • 背景壁紙更新
  • 與照片畫廊應用整合

主要特色

  • 非同步壁紙設定
  • 對影片即時壁紙的支援
  • 僅限 Android 的平台相容性
  • 簡單的 API 結合
  • 非阻塞UI操作

適合對象

  • Android應用開發者
  • 壁紙自定義應用
  • 照片和媒體應用
  • 使用者體驗提升專案
  • 需要動態背景變更的應用程式

使用建議

  • 僅限 Android 平台
  • 需要執行時權限
  • 影片壁紙支援取決於裝置功能
  • 可能無法在所有 Android 版本上運作
  • 視頻壁紙可能會影響電池壽命

原始 README

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

async_wallpaper

pub package

Flutter plugin to set wallpapers on Android and save them to Photos on iOS.

  • Static wallpaper from a URL, file path, content URI, or bytes
  • Home, lock, or both targets, with a separate result for each
  • Video and OpenGL live wallpapers
  • Scheduled wallpaper rotation
  • Capability checks before you show an action

Screenshots

Static wallpaper Capabilities More APIs iOS

Video live wallpaper: home screen before, the system preview, and the applied video.

Scale modes: centerCrop, fitCenter, center, fill, and stretch on a 1080x2400 phone.

Requirements

  • Flutter >=3.41.4, Dart >=3.9.0
  • Android minSdk 24
  • iOS 13.0+ (download only)

Installation

dependencies:
  async_wallpaper: ^3.3.0
import 'package:async_wallpaper/async_wallpaper.dart';

Usage

Check capabilities
final c = await AsyncWallpaper.getCapabilities();
if (c.supportsStaticWallpaper && c.canSetWallpaper) {
  // Show the action.
}
Static wallpaper
final result = await AsyncWallpaper.applyWallpaper(
  const StaticWallpaperRequest(
    source: WallpaperSource.url('https://example.com/wallpaper.jpg'),
    target: WallpaperTarget.both,
    scaleMode: WallpaperScaleMode.centerCrop,
    strategy: WallpaperApplyStrategy.direct,
  ),
);
if (result.status == WallpaperOperationStatus.applied) {
  // For `both`, read `result.home` and `result.lock`.
}

Sources: WallpaperSource.url (HTTPS), filePath, contentUri, bytes.

Video live wallpaper
final req = VideoWallpaperRequest(
  source: WallpaperSource.filePath('/storage/emulated/0/Download/loop.mp4'),
  target: WallpaperTarget.home,
);
final prepared = await AsyncWallpaper.setVideoWallpaper(req);
if (prepared.status == WallpaperOperationStatus.awaitingUserConfirmation) {
  await AsyncWallpaper.openLiveWallpaperPreview(req);
}

previewOpened means the system preview opened, not that the user applied it.

OpenGL live wallpaper

Check supportsOpenGlLiveWallpaper first, then call setOpenGlLiveWallpaper with a GLSL ES 1.00 fragment shader (1-60 FPS).

Wallpaper rotation
await AsyncWallpaper.startWallpaperRotation(
  const WallpaperRotationRequest(
    sources: <WallpaperRotationSource>[
      WallpaperRotationSource(sourceType: WallpaperSourceType.url, source: 'https://example.com/1.jpg'),
      WallpaperRotationSource(sourceType: WallpaperSourceType.file, source: '/storage/emulated/0/Download/2.jpg'),
    ],
    target: WallpaperTarget.both,
    intervalMinutes: 60,
    order: WallpaperRotationOrder.shuffle,
    triggers: <WallpaperRotationTrigger>{
      WallpaperRotationTrigger.interval,
      WallpaperRotationTrigger.charging,
      WallpaperRotationTrigger.timeOfDay,
    },
    activeHoursStart: 6,
    activeHoursEnd: 23,
  ),
);
await AsyncWallpaper.getWallpaperRotationStatus();
await AsyncWallpaper.rotateWallpaperNow();
await AsyncWallpaper.stopWallpaperRotation();

The minimum interval is 15 minutes. URLs must be HTTPS. Rotation uses WorkManager and needs no foreground service.

Download
await AsyncWallpaper.downloadWallpaper(
  const DownloadWallpaperRequest(url: 'https://example.com/wallpaper.jpg'),
);
  • iOS: add NSPhotoLibraryAddUsageDescription to Info.plist.
  • Android 9 and older: declare WRITE_EXTERNAL_STORAGE with android:maxSdkVersion="28" and request it before you call downloadWallpaper.

Platform support

Android iOS Web/desktop
Static, live, OpenGL, rotation Yes unsupported unsupported
Download Yes Yes unsupported
  • Background work (for example WorkManager): use WallpaperApplyStrategy.direct. The cropper, picker, and live previews need a foreground Activity and return foregroundRequired otherwise.
  • The plugin shows no toasts and does not navigate. Your app shows its own UI from the result.

Docs

Contributing

Report bugs with the bug report template and include the device model, Android version, and steps to reproduce. Request features with the feature request template. Read CONTRIBUTING.md before you open a PR.

License

MIT

所屬分類

原始碼儲存庫

使用此套件的專案