Home > Mobile >  The value of the local variable isn’t used In Dart
The value of the local variable isn’t used In Dart

Time:08-12

void main() {
  List Users = [
    {"Name": "Mohamed", "Age": 21, "Phone": 3303304, "password": "nerkl"},
    {"Name": "Ahmed", "Age": 34, "Phone": 2299833, "password": "bftjss"}
  ];
}

CodePudding user response:

It's just a warning, not an error. The compiler sees your program is if it's completely finished. Since you don't actually use Users yet it gives you the warning, because it means you could delete those lines and it doesn't change the behaviour of your program at all. It's normal to see this a lot while you are still developing. Once you do something with the Users variable the warning will go away. Like if you write a simple

print(Users);

you will notice the warning goes away. Also a small advice: The usual coding conventions are that you don't write variables with a capital letter, this is usually only done for class names. So I would change it to users but that is all up to you.

CodePudding user response:

The variables you declared are never used, only assigned to, therefore you're being warned.

  •  Tags:  
  • dart
  • Related