-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Consider the following code:
void deserialize(List<Map> value) {
}
String source = '[{"id": "1"}]';
var obj = json.decode(source);
assert(obj is List);
deserialize(obj);
As obj is a List<dynamic> and deserialize() expects a List<Map>, the above code would fail with the following error:
I/flutter ( 9844): type 'List<dynamic>' is not a subtype of type 'List<Map<dynamic, dynamic>>'
This is an expected error. However, I countered a situation where no error is reported in the console executing a similar method call. The call simply failed silently, leaving the developer (me) in the dark. It happened when I attempted to deserialize a json string to a list of objects using jaguar_serializer. The code stopped working after I have updated to the latest dev version of Flutter. Setting breakpoints won't help, the code appeared to exit just before the offending line in step-by-step mode.
I've uploaded a repo with code that reproduces this issue. Here is the offending line.
Interestingly, when I was creating a new project to try to isolate the issue, I once saw Android Studio stopped the execution and highlighted the offending line with the type 'List<dynamic>' is not a subtype of ... error on the tooltop (which is why I now know it's a type error. Otherwise I would be clueless). This is as if an exception breakpoint has been set (it hasn't). But no error is shown on the console, and it only happened once.
So I tried enabling the exception breakpoint, ran the code again, and found the breakpoint worked for the first few times (3-4 times I think). Then nothing happened anymore, and I'm yet to find a way to make Android Studio break again on the same line. And again, no error was reported whatsoever on the console, no matter the breakpoint worked or not.
[√] Flutter (Channel dev, v0.5.8, on Microsoft Windows [Version 10.0.17134.165], locale zh-HK)
• Flutter version 0.5.8 at C:\flutter
• Framework revision e4b989bf3d (3 days ago), 2018-08-09 09:45:44 -0700
• Engine revision 3777931801
• Dart version 2.0.0-dev.69.5.flutter-eab492385c
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at C:\Users\CY\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• Java binary at: C:\Program Files\Android\Android Studio 3\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
• All Android licenses accepted.
[!] Android Studio (version 3.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 22.2.1
• Dart plugin version 171.4424
X Unable to determine bundled Java version.
• Try updating or re-installing Android Studio.
[√] Android Studio (version 3.1)
• Android Studio at C:\Program Files\Android\Android Studio 3
• Flutter plugin version 27.1.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[!] Android Studio (version 2.1)
• Android Studio at C:\Android\android-studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
X Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
[!] VS Code, 64-bit edition (version 1.23.0)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected devices (1 available)
• Nexus 5X • 00e1c63e154fae10 • android-arm64 • Android 8.1.0 (API 27)
! Doctor found issues in 3 categories.