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

Expected a value of type '(() => Map<String, String>)?', but got one of type '() => Map<String, dynamic>' #8

Closed
HevelMc opened this issue Jul 9, 2021 · 3 comments

Comments

@HevelMc
Copy link
Contributor

HevelMc commented Jul 9, 2021

This error occurs since the last commit, probably because of the firstWhere() line 431 (although I don't know why).

I haven't found any way to fix this bug except replacing the firstWhere with something else (forEach + return when the condition is valid)
I put my solution in a pull request if you want to accept it.

@hslbetto
Copy link
Member

hslbetto commented Jul 9, 2021

Hi @HevelMc, can you show me the use case and the error returned?
Your solution are a different way to do the same thing.

@HevelMc
Copy link
Contributor Author

HevelMc commented Jul 14, 2021

Hello, sorry it took me a while to reply, but I finally understood why the error appeared (well more or less understood).

This code returns the error indicated above:

List<String> companyListDropdown = [
    "Andralude",
    "Orange",
    "SupOptique",
    "Thales"
];
return SelectFormField(
    onChanged: print,
    initialValue: "Toutes",
    labelText: "Entreprise",
    items: companyListDropdown
        .map((e) => {"value": e})
        .toList(),
),

But if I modify the line with map function to:

.map((e) => {"value": e as dynamic})

The problem is fixed.

I think that the problem comes from the way firstWhere works, because with the forEach (#9) the problem does not appear.

hslbetto pushed a commit that referenced this issue Jul 27, 2021
@hslbetto
Copy link
Member

Check version 2.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants