Search code examples
flutterdartlinter

MapEntry - specify type annotation


I'm using a linter package to practice strict coding, however, I can't figure out how to solve this warning. The code is working but I just want to understand this warning and how to solve this. I'm new to flutter by the way. Hope someone can answer my question. TIA!

Actual Code

PS: sorry, unable to display image because of restriction


Solution

  • The lint you're getting is from pedantic's always_specify_types property. It means that you have to specify the type of the variable. In your case, you need to specify the type of your MapEntry. By default, MapEntry's key and value's type will be dynamic. You'd have to specify it as MapEntry<int,Tab>.

    In simple terms, instead of:

    var number = 12; // dynamic means that the type can be anything (Eg: String, int, etc.)
    

    do:

    int number = 12;