flutter_workmanager icon indicating copy to clipboard operation
flutter_workmanager copied to clipboard

Why need to check type of input data

Open deverlex opened this issue 11 months ago • 2 comments

if (inputData != null) {
      for (final entry in inputData.entries) {
        final key = entry.key;
        final value = entry.value;
        if (!(value is int ||
            value is bool ||
            value is double ||
            value is String ||
            value is List<int> ||
            value is List<bool> ||
            value is List<double> ||
            value is List<String>)) {
          throw Exception(
              "argument $key has wrong type. WorkManager supports only int, bool, double, String and their list");
        }
      }
    }

I want to send dynamic object to inputData. It has an error because you check datatype of input data

deverlex avatar Mar 04 '24 12:03 deverlex

It is because the native android workmanager support only primitive datatypes or their array variants as input. Therefore, you can't pass your custom objects as input. Ref: https://developer.android.com/develop/background-work/background-tasks/persistent/getting-started/define-work#input_output Ref: https://developer.android.com/reference/androidx/work/Data

Prince2347X avatar Apr 02 '24 04:04 Prince2347X

It is because the native android workmanager support only primitive datatypes or their array variants as input. Therefore, you can't pass your custom objects as input. Ref: https://developer.android.com/develop/background-work/background-tasks/persistent/getting-started/define-work#input_output Ref: https://developer.android.com/reference/androidx/work/Data

thank you. I think the native android need change for dynamic

deverlex avatar Apr 02 '24 04:04 deverlex