by @kodeazy
flutter Too few positional arguments required error?
In this blog we will discuss on how to resolve Too few positional arguments: 1 required, 0 given.
I was trying to learn Named parameters
in flutter.
Below is my code to multiply two numbers in flutter.
void main() {
int result=multi(b: 3);
print(result);
}
int multi(int b){
return 2*b;
}
while trying to execute getting below screenshot error.
To resolve the above error modify parameter b
in below function
int multi(int b){
return 2*b;
}
as
int multi({required int b}){
return 2*b;
}
Modified code
Below is the example code after modification.
void main() {
int result=multi(b: 3);
print(result);
}
int multi({required int b}){
return 2*b;
}
Output
6