Reputation: 11
I am creating a loan calculator using finance: ^0.1.0 package from pub.dev/packages/finance. I am getting an error at c['ipmt'] while calculating the total interest paid. The error is The argument type 'num?' can't be assigned to the parameter type 'num'.dart(argument_type_not_assignable).
Please help.
Upvotes: 1
Views: 767
Reputation: 77304
Your compiler does not know that a given map contains a value. You as teh programmer are reasonably sure because you added it, but the compiler is not smart enough.
The lesson here is to create an actual type when you are sure what the data looks like. Instead of a map with properties that rely on you typing them correctly every time you access them, create a class with those properties. Then your compiler will know that at this point in the program, this property cannot be null.
Upvotes: 1