Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why need to check type of input data #542

Open
deverlex opened this issue Mar 4, 2024 · 2 comments
Open

Why need to check type of input data #542

deverlex opened this issue Mar 4, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@deverlex
Copy link

deverlex commented Mar 4, 2024

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 deverlex added the bug Something isn't working label Mar 4, 2024
@Prince2347X
Copy link

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

@deverlex
Copy link
Author

deverlex commented Apr 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants