Flutter 应用发送数据失败——时间不够

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

应用程序用于测量步数,目标是如果它不小心关闭,在此之前它会向服务器发送请求以保存步数。

应用程序关闭导致应用程序无法向服务器发送数据,如何解决?

应用程序似乎没有时间。

case AppLifecycleState.detached:
        var steps =
            Provider.of<StepsProvider>(context, listen: false).getTotalSteps;
        if (steps != '0') {
          //Yup, the code works here, but don't have time to send requests to the server or save local storage data.
          await StepsBackUp(steps: steps).saveBackUpSteps(); // same for local storage
          await PedometerService(steps: steps).saveRecord();
        }
        break;
flutter http backup
© www.soinside.com 2019 - 2024. All rights reserved.