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

Overview

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
  • 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.

Comments
  • Not working from Android 6.0 to downward

    Not working from Android 6.0 to downward

    No error display...

    I used this code but Android 6 to downward its not set wallpaper await WallpaperManager.setWallpaperFromFile( file.path, WallpaperManager.HOME_SCREEN);

    opened by huzaifasaeed 12
  • Unhandled Exception: MissingPluginException(No implementation found for method setWallpaperFromAsset on channel wallpaper_manager)

    Unhandled Exception: MissingPluginException(No implementation found for method setWallpaperFromAsset on channel wallpaper_manager)

    I am getting this MissingPluginException error while using method setwallpaperfromasset, setwallpaperfromfile works fine, please tell me solution, my device is android running with API 29 1

    opened by EditedSix 5
  • Uses a deprecated API, please fix this

    Uses a deprecated API, please fix this

    Note: C:\Users\athul\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\wallpaper_manager-1.0.7\android\src\main\java\com\mulgundkar\wallpaper_manager\WallpaperManagerPlugin.java uses or overrides a deprecated API.

    opened by athul-ain 4
  • Set Lock Screen Wallpaper not working in Redmi Note 8

    Set Lock Screen Wallpaper not working in Redmi Note 8

    Some users with Redmi Note 8 in my app are reporting this kind of error (set lock screen not working) , only happens in Lock Screen and only with this smartphone, with other phones are okay. Home Screen also are okay.

    opened by praonde 3
  • GeneratedPluginRegistrant.java:20: error: non-static method registerWith(Registrar) cannot be referenced from a static context

    GeneratedPluginRegistrant.java:20: error: non-static method registerWith(Registrar) cannot be referenced from a static context

    resim

    resim

    resim

      String path = file.path;
      int location = WallpaperManager
          .HOME_SCREEN; // or location = WallpaperManager.LOCK_SCREEN;
      String result;
      try {
        result = await WallpaperManager.setWallpaperFromFile(path, location);
      } on Exception {
        result = 'Failed to get wallpaper.';
      }
    
    opened by Flaccuss 3
  • Android resource linking failed

    Android resource linking failed

    Hello im having this error on release mode only it doesnt show on debug,run or profile. im also able to build App bundle successfully. i also tried building without this line: android:theme="@style/LaunchTheme"

    Execution failed for task ':wallpaper_manager:verifyReleaseResources'.

    A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade

    1 exception was raised by workers:

     com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
    
     C:\src\sdk\flutter\.pub-cache\hosted\pub.dartlang.org\wallpaper_manager-1.0.6\android\src\main\AndroidManifest.xml:7:9-12:15: AAPT: error: resource style/LaunchTheme (aka com.mulgundkar.wallpaper_manager:style/LaunchTheme) not found.
    

    `

    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="1111111111"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
          android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    
    
    
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="111111111111111111111111111111"/>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    
    
    </application>
    

    `

    this is the files its looking for i think? <?xml version="1.0" encoding="utf-8"?> <resources> <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar"> <!-- Show a screens.splash screen on the activity. Automatically removed when Flutter draws its first frame --> <item name="android:windowBackground">@drawable/launch_background</item> </style> </resources>

    Flutter doctor `[√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.18363.535], locale en-US) • Flutter version 1.12.13+hotfix.9 at C:\src\sdk\flutter • Framework revision f139b11009 (4 weeks ago), 2020-03-30 13:57:30 -0700 • Engine revision af51afceb8 • Dart version 2.7.2

    [√] Android toolchain - develop for Android devices (Android SDK version 29.0.3) • Android SDK at C:/Users/09370755/AppData/Local/Android/Sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.3 • ANDROID_HOME = C:/Users/09370755/AppData/Local/Android/Sdk • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04) • All Android licenses accepted.

    [√] Android Studio (version 3.6) • Android Studio at C:\Program Files\Android\Android Studio1 • Flutter plugin version 44.0.2 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

    [√] IntelliJ IDEA Community Edition (version 2019.3) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.3 • Flutter plugin version 45.1.2 • Dart plugin version 193.6911.31

    [√] Connected device (1 available) • SM N960F • 26715611da1c7ece • android-arm64 • Android 10 (API 29)

    • No issues found! Process finished with exit code 0`

    opened by MuhammadAkkad 2
  • No effect when I set the LOCK_SCREEN status

    No effect when I set the LOCK_SCREEN status

    version :android 8.1.0

    No effect when I set the LOCK_SCREEN status

    why?

    try {
      result = await WallpaperManager.setWallpaperFromAsset(
          assetPath, WallpaperManager.LOCK_SCREEN);
    } on PlatformException {
      result = 'Failed to get wallpaper.';
    }
    
    opened by zhoutongbie 2
  • Add an option to set both home screen and lock screen

    Add an option to set both home screen and lock screen

    It would be useful to have a constant like WallpaperManager.BOTH, so we could set both lock screen and home screen in one method call. I think this may also be a workaround for #6.

    opened by timekone 1
  • Not setting image as wallpaper properly

    Not setting image as wallpaper properly

    When I load low quality image (< 200 KB) it sets properly, but when I want to set larger image (600+ KB),sometimes it doesn't load image at all, at times does or loads with black rectangles (not full image).

    opened by kam-ox 0
  • Setting wallpaper with crop centralization

    Setting wallpaper with crop centralization

    i am trying to set wallpaper without being scrolled here is my function

    var data = jsonDecode(dat);
        var aspectRatio = data['aspectRatio'];
        if (data['type'] == 1) {
          try {
            String url = data['url'];
            int location = WallpaperManager.HOME_SCREEN;
            File file = await DefaultCacheManager().getSingleFile(url);
            var decodedImage = await decodeImageFromList(file.readAsBytesSync());
            print(decodedImage.height);
    
            final String result =
                await WallpaperManager.setWallpaperFromFileWithCrop(
                    file.path,
                    location,
                    0,
                    0,
                    (aspectRatio * decodedImage.width).toInt(),
                    (( aspectRatio) * decodedImage.height).toInt());
            print(result);
          } on PlatformException {
            print('Failed to get wallpaper.');
          }
    
      i searched alot but i can't find a way to centralize it 
      thx in advance
    
    opened by Epic-Apps-Hub 2
  • Add Null Safety Support

    Add Null Safety Support

    Adding Null Safety and Remove Deprecated Widget

    Changelog

    • Migrate to flutter: 2.2.3
    • Migrate to Null Safety Code
    • Renew Example to Null Safety

    I hope this can help other users who use this package thanks :)

    opened by perymerdeka 0
  • Error when setting wallpaper both screens

    Error when setting wallpaper both screens

    When use set both screens, my app only sets the home screen but the lock screen turns back to its wallpaper before.

    Does anyone get a solution for this one ? @@

    opened by ninoorta 0
Owner
Aditya Mulgundkar
Scouting the research terrain as a Mentor, Full Stack Developer & a robotics enthusiast.
Aditya Mulgundkar
Flutter - Passcode Lock Screen

Flutter - Passcode Lock Screen A Flutter package for iOS and Android for showing passcode input screen, similar to Native iOS. Installation First add

Vladimir Hudnitsky 160 Dec 25, 2022
This package gives you lock screen or pass code page

Flutter Pass Code Page or Pin Code Page Package This package gives you beautiful pass code page for using both android and ios. Demo Finger Print Usag

Yasin ilhan 61 Aug 22, 2022
Home-Service-App - Home Service App Built With Flutter

Home-Service-App Home Service App Sample Images

Justin Roy 2 Sep 4, 2022
Smart home UI - A Flutter UI for Smart Home App

smart_home_app UI for Smart Home App Images

Aymen Ziouche 11 Dec 22, 2022
Klutter plugin makes it possible to write a Flutter plugin for both Android and iOS using Kotlin only.

The Klutter Framework makes it possible to write a Flutter plugin for both Android and iOS using Kotlin Multiplatform. Instead of writing platform spe

Gillian 33 Dec 18, 2022
Flutter plugin to manage home screen widget within flutter app.

Flutter App Widget App Widget / Home Screen widget plugin for flutter app Usage Please see app_widget subdirectory for the usage documentation. Plafor

Alexander Dischberg 6 Dec 16, 2022
Flutter plugin for creating static & dynamic app shortcuts on the home screen.

Flutter Shortcuts Show some ❤️ and ⭐ the repo Why use Flutter Shortcuts? Flutter Shortcuts Plugin is known for : Flutter Shortcuts Fast, performant &

Divyanshu Shekhar 39 Sep 26, 2022
Flutter plugin for creating static & dynamic app shortcuts on the home screen.

Flutter Shortcuts Compatibility ✅ Android ❌ iOS (active issue: iOS support for quick actions) Show some ❤️ and ⭐ the repo Why use Flutter Shortcuts? F

Devs On Flutter 39 Sep 26, 2022
Status Stepper: Use this package for showing status changing

status_stepper Use this package for showing status changing. For now available o

Progressive Mobile 0 Jan 11, 2022
A small transitioning dynamic app showing Dice changing Behavior

Dice_App A new Flutter project.This is a small transitioning dynamic app showing Dice changing Behavior. Getting Started This project is a starting po

Avinandan Bose 1 Mar 20, 2022
Rotate Dial Lock

Rotary dial Locker Dependencies : How it works Most magic handle by GuesterDetector. onPanEnd onPanDown onPanUpdate SpringHouse, 1st we locate where u

Md. Yeasin Sheikh 10 Dec 21, 2022
Android test task master - Create PIN code screen, authentication by PIN code screen and menu screen

Here is described test tasks for a android dev. Need to implement three screens:

null 3 Oct 4, 2022
Flutter blue plus - Flutter plugin for connecting and communicationg with Bluetooth Low Energy devices, on Android and iOS

Introduction FlutterBluePlus is a bluetooth plugin for Flutter, a new app SDK to

null 141 Dec 22, 2022
Flutter Local Notifications - Learn how to implement local notifications into both Android and iOS using flutter_local_notifications plugin.

Flutter Local Notifications Example Flutter Local Notifications - Learn how to implement local notifications into both Android and iOS using flutter_l

Sandip Pramanik 12 Nov 29, 2022
A Flutter sensor plugin which provide easy access to the Pitch and Roll on Android and iOS devices.

Flutter Aeyrium Sensor Plugin Aeyrium Sensor Plugin A Flutter sensor plugin which provide easy access to the Pitch and Roll on Android and iOS devices

Aeyrium 58 Nov 3, 2022
Flutterbodydetection - A flutter plugin that uses MLKit on iOS/Android platforms to enable body pose and mask detection using Pose Detection and Selfie Segmentation APIs for both static images and live camera stream.

body_detection A flutter plugin that uses MLKit on iOS/Android platforms to enable body pose and mask detection using Pose Detection and Selfie Segmen

null 18 Dec 5, 2022
A Flutter plugin to get location updates in the background for both Android and iOS

Background Location A Flutter plugin to get location updates in the background for both Android and iOS (Requires iOS 10.0+). Uses CoreLocation for iO

Ali Almoullim 181 Jan 4, 2023
A Flutter App with animation on login and home screen

Animação com Flutter Sobre: App com animação na tela de login e home. Obs: Sem validação, somente foi feito o teste para animação da tela Imagens: LOG

null 2 Nov 9, 2022
A fully-featured Last.fm client and scrobbler with Shazam-like scrobbling, a collage generator, home screen widgets, and more!

Finale A fully-featured Last.fm client and scrobbler with Shazam-like scrobbling, a collage generator, and more! The app is available on iOS, Android,

Noah Rubin 66 Jan 5, 2023