I have this function called add which adds two numbers and returns the result in dart.
void main() {
int step1Result = add(n1: 5, n2: 9);
int step2Result = multiply(step1Result, 5);
double finalResult = step2Result / 3;
print(finalResult);
}
int add({int n1, int n2}){
return n1 + n2;
}
but it keeps on throwing the error that n1
and n2
can't have a value of 'null' because of its type, but the implicit default value is 'null'.
I tried adding the ?
mark but the it threw another error saying
The operator '+' can't be unconditionally invoked because the receiver can be 'null'.