[英]Flutter lint rules - Avoid method calls or property accesses on a "dynamic" target
我正在解決 lint 問題,所以我需要幫助解決“動態”目標上的避免方法調用或屬性訪問這一問題。
我的代碼如下:
class FlavorValues {
String? baseUrl;
String? name;
String? ocpApimSubscriptionKey;
FlavorValues(dynamic value) {
baseUrl = value['baseUrl']; // value throwing the lint
name = value['appName']; // value throwing the lint
ocpApimSubscriptionKey = value['ocpApimSubscriptionKey'];
}
}
拋出 lint 的行是:baseUrl = value['baseUrl'];
請改用Map
。
像這樣:
FlavorValues(Map<String, dynamic> value) {
baseUrl = value['baseUrl'];
name = value['appName'];
ocpApimSubscriptionKey = value['ocpApimSubscriptionKey'];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.