wallpaper_x 0.0.1+1 copy "wallpaper_x: ^0.0.1+1" to clipboard
wallpaper_x: ^0.0.1+1 copied to clipboard

PlatformAndroid

Set Android wallpapers asynchronously, including video live wallpapers, for a seamless, non-blocking app experience.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:path_provider/path_provider.dart';
import 'package:wallpaper_x/wallpaper_x.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final String _videoPath = 'assets/test.mp4';
  final _wallpaperXPlugin = WallpaperX();

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
            child: ElevatedButton(
                onPressed: () => _setLiveWallpaper(),
                child: const Text('Set LiveWallpaper'))),
      ),
    );
  }

  Future<void> _setLiveWallpaper() async {
    final content = await rootBundle.load(_videoPath);
    final buffer = content.buffer.asUint8List();
    final appDir = await getApplicationSupportDirectory();
    String wallpaperPath = '${appDir.path}/wallpaper.mp4';
    File f = File(wallpaperPath);
    await f.writeAsBytes(buffer);
    await _wallpaperXPlugin.setLiveWallpaper(filePath: wallpaperPath);
  }
}
1
likes
160
points
12
downloads

Publisher

unverified uploader

Weekly Downloads

Set Android wallpapers asynchronously, including video live wallpapers, for a seamless, non-blocking app experience.

Homepage
Repository (GitHub)
View/report issues

Topics

#wallpaper #livewallpaper

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on wallpaper_x