搜索插件、代码仓与 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

所属分类

源码仓库

使用此插件的项目