wallflower: Flutter live wallpapers for Android
Build an Android live wallpaper from ordinary Flutter widgets: animated scenes, parallax that follows home screen swipes and device tilt, and tap effects. Other wallpaper packages set an image, a video or a shader; wallflower runs your widget tree as the live wallpaper.
Features
- Any widget as the wallpaper, drawn by the same renderer as your app.
MediaQueryandSafeAreawork as usual. - Parallax that follows home screen swipes and device tilt.
- Taps and launcher zoom: pointer events, taps on empty home screen space, and the zoom as the app drawer opens.
- Settings and messages between your app and the running wallpaper.
- Home screen, lock screen or both, and the system picker's preview.
- Material You: report the scene's colors, and the system theme and status bar icons follow them.
- Battery-aware and fail-safe: no frames while the wallpaper is hidden, no motion sensor unless something reads tilt, and a solid color instead of a crash if the engine can't start.
Requirements
- Android 7.0 (API 24) or later. iOS has no live wallpaper API.
- Flutter 3.44 or later.
In an app that also builds for other platforms, call LiveWallpaper only on Android; elsewhere it
throws a MissingPluginException.
Quick start
These steps turn a Flutter app into a live wallpaper. The Getting started guide walks through them in more detail.
1. Add the package:
flutter pub add wallflower
2. Declare the wallpaper in android/app/src/main/AndroidManifest.xml. Add <uses-feature>
inside <manifest>, and <service> inside <application>:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature android:name="android.software.live_wallpaper" android:required="false" />
<application ...>
<activity ...>...</activity>
<service
android:name="app.sharpsan.wallflower.FlutterWallpaperService"
android:label="@string/wallpaper_label"
android:permission="android.permission.BIND_WALLPAPER"
android:exported="true">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper" android:resource="@xml/wallpaper" />
<meta-data android:name="wallflower.entrypoint" android:value="wallpaperMain" />
</service>
</application>
</manifest>
3. Describe it for the wallpaper picker. Create android/app/src/main/res/xml/wallpaper.xml:
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/wallpaper_description"
android:thumbnail="@mipmap/ic_launcher" />
and create (or add to) android/app/src/main/res/values/strings.xml:
<resources>
<string name="wallpaper_label">My wallpaper</string>
<string name="wallpaper_description">A live wallpaper made with Flutter.</string>
</resources>
4. Write the wallpaper. Replace lib/main.dart with:
// lib/main.dart
import 'package:flutter/material.dart';
import 'package:wallflower/wallflower.dart';
/// The app: a button that opens the system's wallpaper preview.
void main() => runApp(const MyApp());
/// The wallpaper. Its name matches the `wallflower.entrypoint` meta-data.
@pragma('vm:entry-point')
void wallpaperMain() => runWallpaper(const MyScene());
class MyScene extends StatelessWidget {
const MyScene({super.key});
@override
Widget build(BuildContext context) {
// 0 on the first home screen page, 1 on the last.
final page = Wallpaper.pageOffsetOf(context).dx;
return ColoredBox(color: Color.lerp(Colors.indigo, Colors.orange, page)!);
}
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: FilledButton(
onPressed: LiveWallpaper.openPicker,
child: Text('Set as wallpaper'),
),
),
),
);
}
}
@pragma('vm:entry-point') keeps wallpaperMain in release builds, since no Dart code calls it.
5. Run it with flutter run, tap Set as wallpaper, and apply the wallpaper. Swipe between
home screen pages and the color shifts. Debug builds take a few seconds to show the wallpaper;
release builds show it at once.
How it works
Your app now has two entrypoints. main runs the app as usual. wallpaperMain runs whenever the
wallpaper is applied, even while the app is closed: in the app's process, but in a Flutter engine
and Dart isolate of its own. The system picker's preview runs another copy.
The app and the wallpaper share code but not state: a static field set in the app isn't set in the wallpaper. The app passes settings to the wallpaper through a saved config, and the two can send each other messages.
Learn more
Guides, step by step with complete code:
- Getting started:
from
flutter createto a wallpaper on your home screen, and a quick way to work on a scene. - Writing scenes: parallax, launcher zoom, visibility and battery, the lock screen, and Material You colors.
- Motion and touch: device tilt, taps and launcher commands.
- The app and the wallpaper: settings, messages, and several wallpapers in one app.
- Testing and previews: widget tests, and showing a scene inside your app.
The example is the wallpaper in the screenshots above: parallax mountains, particles that ripple where you tap, and a clock, with a settings app that switches between them.
Usage
Scenes read the wallpaper's state the way widgets read MediaQuery, and each method rebuilds the
caller only when its own value changes. runWallpaper adds no MaterialApp; add one inside the
scene if it needs Material widgets or themes.
| Method | Returns |
|---|---|
Wallpaper.visibleOf(context) |
Whether the wallpaper is on screen. Frames stop while it's hidden. |
Wallpaper.pageOffsetOf(context) |
The launcher's scroll position across home screen pages, 0 to 1. |
Wallpaper.zoomOf(context) |
How far the launcher zoomed out for the app drawer or recents, 0 to 1. |
Wallpaper.isPreviewOf(context) |
Whether this is the system picker's preview. |
Wallpaper.targetOf(context) |
Home screen, lock screen or both (Android 14 and later). |
Wallpaper.configOf(context) |
The settings the app saved. |
WallpaperTilt.of(context) |
Device tilt, each axis -1 to 1. |
The app and the wallpaper share a saved config and can send each other messages:
// In the app:
await LiveWallpaper.setConfig({'scene': 'aurora', 'speed': 2}); // saved, and sent to the wallpaper
await LiveWallpaper.send('celebrate'); // one-off message
LiveWallpaper.messages.listen((message) => debugPrint(message.name));
// In the wallpaper:
final config = Wallpaper.configOf(context); // {'scene': 'aurora', 'speed': 2}
Wallpaper.messages.listen((message) { /* 'celebrate' */ });
await Wallpaper.sendToApp('done', data: {'frames': 120});
The config is a JSON-compatible map, saved on the device. Messages reach only the wallpapers and app screens running at the time.
| To | Use | Guide |
|---|---|---|
| React to taps on empty home screen space | Wallpaper.commands |
Motion and touch |
| Theme the system from the scene's colors | Wallpaper.reportColors |
Writing scenes |
| Run a game loop or other code outside the widget tree | Wallpaper.data, WallpaperTilt.listenable |
Writing scenes |
| Test a scene, or preview it in the app | WallpaperScope |
Testing and previews |
| Check or set the wallpaper from the app | LiveWallpaper.isActive, openPicker |
The app and the wallpaper |
| Offer several wallpapers in one app | service: on LiveWallpaper methods |
The app and the wallpaper |
Battery
A live wallpaper is on screen whenever the home screen is, so its cost adds up.
- Hidden wallpapers draw nothing, but Dart timers and streams keep running. Pause them while
Wallpaper.visibleOf(context)is false. - Prefer animations that settle. A scene that changes only on swipes, tilt or taps draws no frames in between. On a Pixel 10 Pro, a static scene used 0.1% of a CPU core while visible, and a simple gradient animating at 60 fps used about a third of a core.
- Read tilt only when you use it. A widget that reads tilt keeps the sensor on until it unmounts, so read it in a small widget of its own. While the phone lies still, the sensor drops to 10 samples a second, and a static scene reading tilt used under 1% of a core on the same phone.
Troubleshooting
- The wallpaper stays black. Check logcat for the tag
Wallflower, which warns if no frame arrives within 5 seconds of the wallpaper becoming visible. Usually the entrypoint's name doesn't match the meta-data, the function lacks@pragma('vm:entry-point'), or it doesn't callrunWallpaper. It must also be in the app's main file (normallylib/main.dart), unless thewallflower.entrypointLibrarymeta-data names its file. - The first frame is slow. Debug builds start the wallpaper in JIT mode, which takes seconds. Profile and release builds show the first frame within about a tenth of a second.
- The wallpaper reset to the system default. Android removes a live wallpaper when its app is
force-stopped, uninstalled, or crashes repeatedly.
flutter runforce-stops the app when it starts and when you quit withq; detach withdinstead. Updating the app any other way keeps the wallpaper. - Tilt stays at zero. Tilt measures movement away from how the phone is held, so it returns to zero whenever the phone is still. Devices and emulators without a motion sensor always report zero.
Limitations
- Android only.
- Plugins are registered in the wallpaper's engine too, but plugins that need an
Activitywon't get one. - No platform views, text input or accessibility semantics inside the wallpaper.
- Each running copy of the wallpaper (the applied one, and the picker preview while it's open) is a full Flutter engine. On a Pixel 10 Pro, a simple animated scene's process used about 185 MB, and about 75 MB more while the preview was open. Flutter keeps about half a megabyte of each engine after it shuts down, which adds up only if the preview opens many times in one process.
Libraries
- wallflower
- Live wallpapers for Android built from Flutter widgets.