飞镖 "Try adding an explicit type like 'dynamic', or enable implicit-dynamic in your analysis options file."
Flutter DART "Try adding an explicit type like 'dynamic', or enable implicit-dynamic in your analysis options file."
我使用 Flutter 并遇到以下警告analysis_options.yaml。
Missing type arguments for map literal.
Try adding an explicit type
like 'dynamic', or enable implicit-dynamic in your analysis options
file.
代码如下
Map<String, dynamic> toJson() => {
'name': name,
'isEnabled': isEnabled,
};
如何修复此警告?
扑博士
C:\src\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, 1.20.4, on Microsoft Windows [Version 10.0.18363.1082], locale ja-JP)
• Flutter version 1.20.4 at C:\src\flutter
• Framework revision fba99f6cf9 (5 days ago), 2020-09-14 15:32:52 -0700
• Engine revision d1bc06f032
• Dart version 2.9.2
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at C:\Users\user\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 48.1.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
通过以下代码解决。
Map<String, dynamic> toJson() => <String, dynamic>{
'name': name,
'isEnabled': isEnabled,
};
我使用 Flutter 并遇到以下警告analysis_options.yaml。
Missing type arguments for map literal.
Try adding an explicit type like 'dynamic', or enable implicit-dynamic in your analysis options file.
代码如下
Map<String, dynamic> toJson() => {
'name': name,
'isEnabled': isEnabled,
};
如何修复此警告?
扑博士
C:\src\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, 1.20.4, on Microsoft Windows [Version 10.0.18363.1082], locale ja-JP)
• Flutter version 1.20.4 at C:\src\flutter
• Framework revision fba99f6cf9 (5 days ago), 2020-09-14 15:32:52 -0700
• Engine revision d1bc06f032
• Dart version 2.9.2
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at C:\Users\user\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 48.1.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
通过以下代码解决。
Map<String, dynamic> toJson() => <String, dynamic>{
'name': name,
'isEnabled': isEnabled,
};