MapEntry - 指定类型注解

MapEntry - specify type annotation

我正在使用 linter 包来练习严格编码,但是,我不知道如何解决这个警告。该代码正在运行,但我只想了解此警告以及如何解决此问题。顺便说一句,我是新手。希望有人能回答我的问题。 TIA!

Actual Code

PS: 抱歉,由于限制无法显示图片

您获得的 lint 来自 pedanticalways_specify_types 属性。这意味着您必须指定变量的类型。在您的情况下,您需要指定 MapEntry 的类型。默认情况下,MapEntry 的键和值的类型将为 dynamic您必须将其指定为 MapEntry<int,Tab>

简单来说,而不是:

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

做:

int number = 12;