postExecute method

  1. @override
Future<void> postExecute(
  1. LocalDatabase localDatabase,
  2. bool success
)
override

To be executed after the actual run.

Mostly, cleans the temporary data changes performed in preExecute. success indicates (if true) that so far the operation was a success. With that bool we're able to deal with 2 cases:

  1. everything is fine and we may have to do something more than cleaning
  2. something bad happened and we just need to clear the task

Implementation

@override
Future<void> postExecute(
  LocalDatabase localDatabase,
  bool success,
) async {
  await super.postExecute(localDatabase, success);
  try {
    (await BackgroundTaskUpload.getFile(fullPath)).deleteSync();
  } catch (e) {
    // not likely, but let's not spoil the task for that either.
  }
  try {
    (await BackgroundTaskUpload.getFile(
      await BackgroundTaskImage.getCroppedPath(fullPath),
    )).deleteSync();
  } catch (e) {
    // possible, but let's not spoil the task for that either.
  }
}