패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.2.0

wallpaper

이 플러그인의 목적은 URL에서 벽지로 설정하는 것입니다. Android에서만 지원됩니다. 내부적으로 WallpaperManager를 사용하여 벽지를 설정합니다.

Android
30일 다운로드
575
좋아요
52
Pub 점수
160

패키지 설치

flutter pub add wallpaper

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

월페이퍼 패키지는 URL을 사용하여 안드로이드 기기에서 배경화면을 설정할 수 있게 해줍니다. 내부적으로 안드로이드 월페이퍼 매니저 API를 활용하여 웹 URL에서 이미지를 배경화면으로 적용합니다. 안드로이드 전용으로 설계되어 iOS는 지원하지 않습니다. 플러그인은 간단하게 통합 가능하며, 사용자가 동적 또는 사용자 선택 이미지로 기기의 홈 화면을 맞춤 설정할 수 있는 앱에 유용합니다. 적절한 권한이 필요하며, 안드로이드를 대상으로 하는 플러터 애플리케이션에서 원활하게 작동합니다.

사용 사례

  • URL에서 동적 배경화면 설정
  • 앱에서 장치 홈 화면 사용자 지정
  • 사용자 배경화면 선택 활성화
  • 배경화면 업데이트 자동화
  • 이미지 기반 테마 통합

주요 기능

  • URL에서 배경화면 설정
  • 네이티브 WallpaperManager API를 사용합니다
  • Android 전용 지원
  • Flutter와의 간단한 통합
  • 원격 이미지 소스를 지원합니다

적합한 대상

  • 안드로이드 앱 개발자
  • 배경화면 사용자 정의 기능
  • 동적 테마 옵션을 갖춘 앱
  • 이미지 기반 사용자 경험
  • 기기 수준의 변경이 필요한 모바일 앱

고려 사항

  • Android에서만 작동합니다
  • 런타임 권한이 필요합니다
  • Android의 WallpaperManager에 제한됨
  • 큰 또는 지원되지 않는 이미지 형식과 함께 실패할 수 있습니다
  • iOS 플랫폼을 지원하지 않습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Wallpaper

A Flutter plugin that allows you to download an image from a URL and set it as wallpaper on Android.

The plugin supports setting wallpapers for:

  • Home screen
  • Lock screen
  • Both screens
  • System wallpaper

Features

  • Download image from URL
  • Track download progress
  • Set wallpaper for home screen
  • Set wallpaper for lock screen
  • Set wallpaper for both screens
  • Set system wallpaper
  • Resize images before setting wallpaper
  • Use modern opt-in fit modes for source-based wallpapers
  • Read the platform-recommended wallpaper size
  • Open the Android system wallpaper chooser

Installation

Add the plugin to your pubspec.yaml:

dependencies:
  wallpaper: ^1.2.0

Then run:

flutter pub get

Android Configuration

The plugin manifest already declares the permissions it needs for downloading network images and setting wallpapers:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SET_WALLPAPER"/>

Downloaded images are stored in app-private cache, files, or external files directories depending on DownloadLocation. Apps using the default workflow do not need READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE, and they do not need to add their own file_paths.xml.


Usage

Import the plugin:

import 'package:wallpaper/wallpaper.dart';

Recommended Wallpaper Size

Use the recommended size when choosing, generating, cropping, or downloading an image for the current Android launcher:

final size = await Wallpaper.recommendedWallpaperSize();
print('${size.width} x ${size.height}');

Open Wallpaper Chooser

Open Android's built-in wallpaper chooser without passing a specific image:

await Wallpaper.openWallpaperChooser();

Download Image

final stream = Wallpaper.imageDownloadProgress(
  imageUrl,
  location: DownloadLocation.applicationDirectory,
);

stream.listen((progress) {
  print(progress);
});

Typed Download Operation

Use download when you need typed progress, headers, timeouts, cache reuse, or cancellation:

final operation = Wallpaper.download(
  imageUrl,
  options: const WallpaperDownloadOptions(
    imageName: 'daily_wallpaper',
    headers: {'Authorization': 'Bearer token'},
    connectTimeout: Duration(seconds: 15),
    receiveTimeout: Duration(seconds: 30),
    cachePolicy: WallpaperCachePolicy.reuse,
  ),
);

operation.progress.listen((progress) {
  print(progress.percentage);
});

final file = await operation.completed;

await Wallpaper.homeScreen(
  imageName: file.imageName,
  fileExtension: file.fileExtension,
  location: file.location,
);

Cancel an active operation:

await operation.cancel();

Clear plugin-managed temporary downloads created by the typed download API:

await Wallpaper.clearCache();

Set Home Screen Wallpaper

await Wallpaper.homeScreen(
  width: width,
  height: height,
  options: RequestSizeOptions.resizeFit,
  location: DownloadLocation.applicationDirectory,
);

Set Lock Screen Wallpaper

await Wallpaper.lockScreen(
  location: DownloadLocation.applicationDirectory,
);

Set Both Wallpapers

await Wallpaper.bothScreen(
  location: DownloadLocation.applicationDirectory,
);

Set System Wallpaper

await Wallpaper.systemScreen(
  location: DownloadLocation.applicationDirectory,
);

Set Wallpaper From a Local File

await Wallpaper.setFromFile(
  file.path,
  target: WallpaperTarget.home,
  options: RequestSizeOptions.resizeFit,
  fit: WallpaperFit.cover,
  alignment: WallpaperAlignment.topCenter,
);

alignment is optional and defaults to center. It applies to WallpaperFit.cover cropping and WallpaperFit.center placement.


Set Wallpaper From Bytes

await Wallpaper.setFromBytes(
  imageBytes,
  target: WallpaperTarget.both,
  fileExtension: ImageFormat.png,
);

Set Wallpaper From an Asset

await Wallpaper.setFromAsset(
  'assets/wallpaper.jpg',
  target: WallpaperTarget.lock,
);

For assets bundled by another package:

await Wallpaper.setFromAsset(
  'assets/wallpaper.jpg',
  package: 'wallpaper_assets',
);

Unified Source API

Use setWallpaperFromSource when you prefer a typed result instead of catching PlatformException from the legacy methods:

final result = await Wallpaper.setWallpaperFromSource(
  source: WallpaperSource.file(file.path),
  options: const WallpaperOptions(
    target: WallpaperTarget.home,
    fit: WallpaperFit.cover,
    alignment: WallpaperAlignment.topCenter,
  ),
);

switch (result) {
  case WallpaperSuccess(:final message):
    print(message);
  case WallpaperFailure(:final exception):
    print('${exception.code}: ${exception.message}');
}

Example

final stream = Wallpaper.imageDownloadProgress(imageUrl);

stream.listen((progress) {
  print("Downloading: $progress");
}, onDone: () async {

  await Wallpaper.homeScreen(
    width: 1080,
    height: 1920,
    options: RequestSizeOptions.resizeFit,
  );

});

Supported Platform

Platform Supported
Android ✅
iOS ❌

Notes

  • Internet connection is required to download images.
  • Lock screen wallpaper requires Android 7.0+ (API 24).
  • Behavior may vary depending on device manufacturer.
  • Starting multiple downloads with the same imageName writes to the same file. Use unique names for concurrent downloads.

License

MIT License

카테고리

의존성

의존성 목록 4 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.