为什么设置壁纸或动态壁纸后Flutter应用会重新启动?

问题描述 投票:0回答:1

我正在使用 async_wallpaper 包,这就是功能

 Future<void> setLiveWallpaper(String liveUrl) async {
    setState(() {
      _liveWallpaper = 'Loading';
    });
    String result;
    var file = await DefaultCacheManager().getSingleFile(liveUrl);
    try {
      result = await AsyncWallpaper.setLiveWallpaper(
        filePath: file.path,
        goToHome: true,//tried false also
        toastDetails: ToastDetails.success(),
        errorToastDetails: ToastDetails.error(),
      )
          ? 'Live Wallpaper set'
          : 'Failed to set live wallpaper.';
    } on PlatformException catch (e) {
      print('PlatformException>>>>>>>>>>>>>.: $e');
      result = 'Failed to set live wallpaper.';
    }
    if (!mounted) return;

    setState(() {
      _liveWallpaper = result;
    });
  }

this is where i dispaly the live wallpapers thumbnails

After Click one of the wallpaper it shows the wallpaper preview

Now look here the problem is it opens a new activity (new tab for preview). After successfully applying the wallpaper when it comes back to the app it starts from splash screen

flutter android-activity crash live-wallpaper
1个回答
0
投票

您可以在此函数中设置SystemNavigator.pop以在应用壁纸后关闭应用程序。这对用户来说是一个很好的方法,因为几乎每个应用程序都使用这种方法,当用户应用壁纸时,应用程序关闭,壁纸显示给用户。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.