Home > Software design >  Flutter `6 positional argument(s) expected, but 1 found.` Try adding the missing arguments
Flutter `6 positional argument(s) expected, but 1 found.` Try adding the missing arguments

Time:10-26

Please help ::

Here in main.dart file access to rest api when in setState() with 6 positional argument(s) expected, but 1 found.

Please see in screenshot.

user_data.dart [1]: https://i.stack.imgur.com/qUeC8.png main.dart [2]: https://i.stack.imgur.com/uy3WR.png

Help in thanks.

CodePudding user response:

well as the error say, you are passing 1 argument where the constructor is expecting 6. so just remove the five parameters starting from the id and only keep userData. Like this:

UserData.fromJson(Map<String, dynamic){
  // same code here
}

CodePudding user response:

You should not expect anything but the data in your .fromJson method. So keep the userData, but get rid of this.id, this.email, etc. Also you can get rid of the late keyword, as the constructor method will initialize the values.

CodePudding user response:

Please give me code rather then screenshot so i will give you perfectly edited code

  • Related