Skip to content

type 'List<dynamic>' is not a subtype of type 'List<String>' #18979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sahil311289 opened this issue Jul 1, 2018 · 25 comments
Closed

type 'List<dynamic>' is not a subtype of type 'List<String>' #18979

sahil311289 opened this issue Jul 1, 2018 · 25 comments
Labels
d: stackoverflow Good question for Stack Overflow

Comments

@sahil311289
Copy link

Restarted app in 2,687ms.
I/ViewRootImpl(20672): ViewRoot's Touch Event : ACTION_DOWN
I/flutter (20672): _MyAppState.activateSpeechRecognizer... 
I/ViewRootImpl(20672): ViewRoot's Touch Event : ACTION_UP
D/SpeechRecognitionPlugin(20672): Current Locale : en_GB
I/flutter (20672): _platformCallHandler call speech.onCurrentLocale en_GB
I/ViewRootImpl(20672): ViewRoot's Touch Event : ACTION_DOWN
I/ViewRootImpl(20672): ViewRoot's Touch Event : ACTION_UP
I/ViewRootImpl(20672): ViewRoot's Touch Event : ACTION_DOWN
I/ViewRootImpl(20672): ViewRoot's Touch Event : ACTION_UP
I/flutter (20672): Dislike
I/flutter (20672): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter (20672): The following assertion was thrown while handling a gesture:
I/flutter (20672): type 'List<dynamic>' is not a subtype of type 'List<String>'
I/flutter (20672): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (20672): more information in this error message to help you determine and fix the underlying cause.
I/flutter (20672): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (20672):   https://github.com/flutter/flutter/issues/new
I/flutter (20672): When the exception was thrown, this was the stack:
I/flutter (20672): #0      _ChatListTileItemState.build.<anonymous closure> (file:///Users/sahil/IdeaProjects/gabhub_anonym_text/lib/live_chat_tab_base.dart:429:85)
I/flutter (20672): #1      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
I/flutter (20672): #2      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:161:9)
I/flutter (20672): #3      TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:123:7)
I/flutter (20672): #4      GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
I/flutter (20672): #5      _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:147:20)
I/flutter (20672): #6      _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
I/flutter (20672): #7      _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
I/flutter (20672): #8      _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
I/flutter (20672): #9      _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
I/flutter (20672): #10     _invoke1 (dart:ui/hooks.dart:134:13)
I/flutter (20672): #11     _dispatchPointerDataPacket (dart:ui/hooks.dart:91:5)
I/flutter (20672): Handler: onTap
I/flutter (20672): Recognizer:
I/flutter (20672):   TapGestureRecognizer#cf6d7(debugOwner: GestureDetector, state: ready, won arena, finalPosition:
I/flutter (20672):   Offset(125.9, 380.8), sent tap down)
I/flutter (20672): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/ViewRootImpl(20672): ViewRoot's Touch Event : ACTION_DOWN
I/ViewRootImpl(20672): ViewRoot's Touch Event : ACTION_UP
@sahil311289
Copy link
Author

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.5 17F77, locale en-IN)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.0-rc1)
    ✗ Android license status unknown.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
[✓] Android Studio (version 3.1)
[✓] IntelliJ IDEA Community Edition (version 2018.1.5)
[✓] VS Code (version 1.23.1)
[✓] Connected devices (1 available)

! Doctor found issues in 1 category.

@sahil311289
Copy link
Author

Assigning a List type to an actual List gives an exception.

type 'List<dynamic>' is not a subtype of type 'List<String>'
Handler: 

@jonahwilliams
Copy link
Member

@sahil311289 this looks like a type error in your code, maybe see sound dart.

For example, you might be doing something like this:

List xs = ["asd", "dss"]; // list<dynamic>
taksesAListOfStrings(xs); // error List<dynamic> is not a subtype of List<String>

@jonahwilliams jonahwilliams added the d: stackoverflow Good question for Stack Overflow label Jul 1, 2018
@sahil311289
Copy link
Author

sahil311289 commented Jul 1, 2018

This is what I'm trying to do:

print('Like');
update(widget.document.reference, LiveChat.fromMap(widget.document.data).like, 'sahil');

In LiveChat class, I'm trying to encode/decode:

import 'dart:collection';

class LiveChat {
  String message;
  DateTime timestamp;
  String university;
  String email;
  dynamic like = new List<String>();
  dynamic dislike = new List<String>();
  dynamic laugh = new List<String>();
  dynamic cry = new List<String>();
  dynamic angry = new List<String>();

  LiveChat(this.message, this.timestamp, this.university, this.email, this.like,
      this.dislike, this.laugh, this.cry, this.angry);

  LiveChat.fromMap(Map<String, dynamic> data) {
    this.message = data['message'];
    this.timestamp = data['timestamp'];
    this.university = data['university'];
    this.email = data['email'];
    this.like = data['like'];
    this.dislike = data['dislike'];
    this.laugh = data['laugh'];
    this.cry = data['cry'];
    this.angry = data['angry'];
  }

  Map<String, dynamic> toMap() => {
        'message': this.message,
        'timestamp': this.timestamp,
        'university': this.university,
        'email': this.email,
        'like': this.like,
        'dislike': this.dislike,
        'laugh': this.laugh,
        'cry': this.cry,
        'angry': this.angry
      };
}

screen shot 2018-07-01 at 11 42 09 am
Even though data['like'] is of type _List, it gives an exception if I initialize 'like' like the following:

List<String> like = new List<String>();

Initializing the list as dynamic doesn't give exception. But adding to it at a later point surely gives one.

Future<bool> update(DocumentReference reference, dynamic likes, String s) async {
    final TransactionHandler updateTransaction = (Transaction transaction) async {

      final DocumentSnapshot freshSnap = await transaction.get(reference);
      Map<String, dynamic> data = new Map();
      likes.add('sahil');   // Exception here

      data.putIfAbsent('like', () => likes);
      await freshSnap.reference.setData(data, merge: true);
      return {'result': true};
    };
    return Firestore.instance.runTransaction(updateTransaction).then((r) => r['result']).catchError((e) {
      print('GabHub dart error: $e');
      return false;
    });
  }

I'm trying to add to an existing list but it fails. The only workaround I have is, to convert the dynamic type to string, split it and then add it to the list. But the whole point of decoding is lost.

@jonahwilliams
Copy link
Member

The problem is your fromMap constructor is reading from a Map<String, dynamic>, so I bet that all of the lists in that map are actually List<dynamic> or just dynamic. Try doing this instead:

List<String> likes;

LiveChat.fromMap(Map<String, dynamic> data) {
  likes = data['likes'].cast<String>();
}

@sahil311289
Copy link
Author

sahil311289 commented Jul 1, 2018

That fixed the type casting error.
Here's another one:

Future<bool> update(DocumentReference reference, List<String> likes, String s) async {
    final TransactionHandler updateTransaction = (Transaction transaction) async {

      final DocumentSnapshot freshSnap = await transaction.get(reference);
      Map<String, List<String>> data = new Map();
      likes.add(s);        // Exception

      data.putIfAbsent('like', () => likes);
      await freshSnap.reference.setData(data, merge: true);
      return {'result': true};
    };
    return Firestore.instance.runTransaction(updateTransaction).then((r) => r['result']).catchError((e) {
      print('GabHub dart error: $e');
      return false;
    });
  }

likes already has 2 String values. So no initailization related issues. I hope it's not a silly error.

@jonahwilliams
Copy link
Member

What is the exception there?

@sahil311289
Copy link
Author

sahil311289 commented Jul 1, 2018

screen shot 2018-07-01 at 12 07 30 pm

Launching lib/main.dart on LG D802 in debug mode...
Initializing gradle...
Resolving dependencies...
Running 'gradlew assembleDebug'...
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
Warning: Missing asset in fonts for BadScript
Warning: Missing asset in fonts for Roboto
Warning: Missing asset in fonts for Roboto
Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk...
I/FlutterActivityDelegate(13081): onResume setting current activity to this
Warning: Missing asset in fonts for BadScript
Warning: Missing asset in fonts for Roboto
Warning: Missing asset in fonts for Roboto
Syncing files to device LG D802...
I/flutter (13081): _MyAppState.activateSpeechRecognizer... 
D/SpeechRecognitionPlugin(13081): Current Locale : en_GB
W/ResourcesManager(13081): Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
W/ResourcesManager(13081): Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
V/NativeCrypto(13081): Registering com/google/android/gms/org/conscrypt/NativeCrypto's 280 native methods...
I/art     (13081): Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java7ExtendedSSLSession>
I/art     (13081): Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java7ExtendedSSLSession>
I/art     (13081): Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java8ExtendedSSLSession>
I/art     (13081): Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java8ExtendedSSLSession>
W/System  (13081): Could not create com.google.android.gms.org.conscrypt.OpenSSLSocketFactoryImpl with ClassLoader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/chat.gabhub.Chat.gabhubanonymtext-1/base.apk"],nativeLibraryDirectories=[/data/app/chat.gabhub.Chat.gabhubanonymtext-1/lib/arm, /vendor/lib, /system/lib]]]: com.google.android.gms.org.conscrypt.OpenSSLSocketFactoryImpl
I/ProviderInstaller(13081): Installed default security provider GmsCore_OpenSSL
D/libc-netbsd(13081): [getaddrinfo]: hostname=xxxxx; servname=(null); cache_mode=(null), netid=0; mark=0
D/libc-netbsd(13081): [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=4; ai_family=0
D/libc-netbsd(13081): [getaddrinfo]: hostname=xxxxx; servname=(null); cache_mode=(null), netid=0; mark=0
D/libc-netbsd(13081): [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=1024; ai_family=0
I/System.out(13081): propertyValue:false
D/libc-netbsd(13081): [getaddrinfo]: hostname=xxxxx; servname=(null); cache_mode=(null), netid=0; mark=0
D/libc-netbsd(13081): [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=4; ai_family=0
I/flutter (13081): _platformCallHandler call speech.onCurrentLocale en_GB
I/ViewRootImpl(13081): ViewRoot's Touch Event : ACTION_DOWN
I/ViewRootImpl(13081): ViewRoot's Touch Event : ACTION_UP
I/ViewRootImpl(13081): ViewRoot's Touch Event : ACTION_DOWN
I/ViewRootImpl(13081): ViewRoot's Touch Event : ACTION_UP
I/flutter (13081): Like
E/flutter (13081): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (13081): type 'Future<dynamic>' is not a subtype of type 'FutureOr<bool>'
E/flutter (13081): #0      _ChatListTileItemState.update (file:///Users/sahil/IdeaProjects/gabhub_anonym_text/lib/live_chat_tab_base.dart:554:90)
E/flutter (13081): <asynchronous suspension>
E/flutter (13081): #1      _ChatListTileItemState.build.<anonymous closure> (file:///Users/sahil/IdeaProjects/gabhub_anonym_text/lib/live_chat_tab_base.dart:429:31)
E/flutter (13081): #2      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (13081): #3      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:161:9)
E/flutter (13081): #4      TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:123:7)
E/flutter (13081): #5      GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (13081): #6      _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:147:20)
E/flutter (13081): #7      _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
E/flutter (13081): #8      _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (13081): #9      _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
E/flutter (13081): #10     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
E/flutter (13081): #11     _invoke1 (dart:ui/hooks.dart:134:13)
E/flutter (13081): #12     _dispatchPointerDataPacket (dart:ui/hooks.dart:91:5)
I/flutter (13081): GabHub dart error: PlatformException(Error performing transaction, java.lang.Exception: Do transaction failed., null)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): Failed to handle method call result
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): java.lang.IllegalStateException: Task is already complete
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at com.google.android.gms.common.internal.Preconditions.checkState(Unknown Source)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at com.google.android.gms.tasks.zzu.zzdr(Unknown Source)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at com.google.android.gms.tasks.zzu.setException(Unknown Source)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at com.google.android.gms.tasks.TaskCompletionSource.setException(Unknown Source)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$3$1.error(CloudFirestorePlugin.java:290)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at io.flutter.plugin.common.MethodChannel$IncomingResultHandler.reply(MethodChannel.java:171)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at io.flutter.view.FlutterNativeView.handlePlatformMessageResponse(FlutterNativeView.java:187)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at android.os.MessageQueue.next(MessageQueue.java:143)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at android.os.Looper.loop(Looper.java:122)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at android.app.ActivityThread.main(ActivityThread.java:5349)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at java.lang.reflect.Method.invoke(Method.java:372)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
E/MethodChannel#plugins.flutter.io/cloud_firestore(13081): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)

@jonahwilliams
Copy link
Member

Possibly related to #17663?

@sahil311289
Copy link
Author

sahil311289 commented Jul 1, 2018

I had that same issue. Got it resolved by playing aorund with data.
The followong works perfectly fine:

Future<bool> update(DocumentReference reference, List<String> likes, String s) async {
    final TransactionHandler updateTransaction = (Transaction transaction) async {

      final DocumentSnapshot freshSnap = await transaction.get(reference);
      Map<String, List<String>> data = new Map();
//      likes.add(s);        // Exception

      List<String> names = new List<String>();
      names.add('Sahil');
      names.add('Jonahwilliams');

      data.putIfAbsent('like', () => names);
      await freshSnap.reference.setData(data, merge: true);
      return {'result': true};
    };
    return Firestore.instance.runTransaction(updateTransaction).then((r) => r['result']).catchError((e) {
      print('GabHub dart error: $e');
      return false;
    });
  }

But as soon as you introduce Firebase data, it starts giving issues.
Maybe it is related. I trust your judgement :)

@sahil311289
Copy link
Author

sahil311289 commented Jul 1, 2018

screen shot 2018-07-01 at 12 19 30 pm

Please notice the difference in the structures of 'likes' and 'names'. Perhaps casting like the following

this.like = data['like'].cast<String>();

is not the best option. Meanwhile, I'll make use of dynamic type, cast it to a String, split it and get the list data. That one would do until this issue gets resolved.

@sahil311289
Copy link
Author

sahil311289 commented Jul 1, 2018

Future<bool> update(DocumentReference reference, dynamic likes, String s) async {
    final TransactionHandler updateTransaction = (Transaction transaction) async {

      final DocumentSnapshot freshSnap = await transaction.get(reference);
      Map<String, List<String>> data = new Map();

      String likesListString = likes.toString();
      likesListString = likesListString.substring(1, likesListString.length-1);
      List<String> likeList = likesListString.split(", ");

      data.putIfAbsent('like', () => likeList);
      await freshSnap.reference.setData(data, merge: true);
      return {'result': true};
    };
    return Firestore.instance.runTransaction(updateTransaction).then((r) => r['result']).catchError((e) {
      print('GabHub dart error: $e');
      return false;
    });
  }

I presumed this would work since I'm making use of pure List type. Guess what? I was wrong. @jonahwilliams: You were right. This is not a type casting issue alone. Here's the result:

Performing hot reload...
Reloaded 3 of 515 libraries in 1,964ms.
I/ViewRootImpl(16691): ViewRoot's Touch Event : ACTION_DOWN
I/ViewRootImpl(16691): ViewRoot's Touch Event : ACTION_UP
I/ViewRootImpl(16691): ViewRoot's Touch Event : ACTION_DOWN
I/ViewRootImpl(16691): ViewRoot's Touch Event : ACTION_UP
I/flutter (16691): Like
E/flutter (16691): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (16691): type 'Future<dynamic>' is not a subtype of type 'FutureOr<bool>'
E/flutter (16691): #0      _ChatListTileItemState.update (file:///Users/sahil/IdeaProjects/gabhub_anonym_text/lib/live_chat_tab_base.dart:557:90)
E/flutter (16691): <asynchronous suspension>
E/flutter (16691): #1      _ChatListTileItemState.build.<anonymous closure> (file:///Users/sahil/IdeaProjects/gabhub_anonym_text/lib/live_chat_tab_base.dart:429:31)
E/flutter (16691): #2      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (16691): #3      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:161:9)
E/flutter (16691): #4      TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:123:7)
E/flutter (16691): #5      GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (16691): #6      _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:147:20)
E/flutter (16691): #7      _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
E/flutter (16691): #8      _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (16691): #9      _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
E/flutter (16691): #10     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
E/flutter (16691): #11     _invoke1 (dart:ui/hooks.dart:134:13)
E/flutter (16691): #12     _dispatchPointerDataPacket (dart:ui/hooks.dart:91:5)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): Failed to handle method call result
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): java.lang.IllegalStateException: Task is already complete
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at com.google.android.gms.common.internal.Preconditions.checkState(Unknown Source)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at com.google.android.gms.tasks.zzu.zzdr(Unknown Source)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at com.google.android.gms.tasks.zzu.setResult(Unknown Source)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at com.google.android.gms.tasks.TaskCompletionSource.setResult(Unknown Source)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$3$1.success(CloudFirestorePlugin.java:283)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at io.flutter.plugin.common.MethodChannel$IncomingResultHandler.reply(MethodChannel.java:169)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at io.flutter.view.FlutterNativeView.handlePlatformMessageResponse(FlutterNativeView.java:187)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at android.os.MessageQueue.next(MessageQueue.java:143)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at android.os.Looper.loop(Looper.java:122)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at android.app.ActivityThread.main(ActivityThread.java:5349)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at java.lang.reflect.Method.invoke(Method.java:372)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
E/MethodChannel#plugins.flutter.io/cloud_firestore(16691): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)

@jonahwilliams
Copy link
Member

runTransaction probably returns a Future<dynamic>, so you would need to update your code to actually return a Future<bool>.

Future<bool> update(DocumentReference reference, dynamic likes, String s) async {
  /* */
  try {
    final result = await Firestore.instance.runTransaction(updateTransaction);
    return true;
  }  catch (err) {
     return false;
  }
}

@zoechi
Copy link
Contributor

zoechi commented Dec 5, 2018

I believe this issue is stale.

@zoechi zoechi closed this as completed Dec 5, 2018
@unibeck
Copy link

unibeck commented Jan 21, 2019

I did what @jonahwilliams suggested with the cast<Type>() and it was working nicely for a while. Though I encountered an error where if the value for the key in the map was null (e.g. not found) and threw the following error:

I/flutter (17982): The method 'cast' was called on null.
I/flutter (17982): Receiver: null
I/flutter (17982): Tried calling: cast<DocumentReference>()

with the following code

Object.fromMap(Map<String, dynamic> map, {this.reference})
    : readBy = map['readBy'].cast<DocumentReference>();

To fix this you can make an ugly inline null check:

readBy = (map['readBy'] != null) ? map['readBy'].cast<DocumentReference>() : null

But the cleaner and more Dartful way of accomplishing this is with the null-aware ?. operator:

readBy = map['readBy']?.cast<DocumentReference>()

Leaving this slight improvement here encase anyone else comes across this issue.

@vivekanandasuggu
Copy link

vivekanandasuggu commented Jun 28, 2019

My model class is like this

`import 'dart:convert';

List serviceLogsModelFromJson(String str) => new List.from(json.decode(str).map((x) => ServiceLogsModel.fromJson(x)));

String serviceLogsModelToJson(List data) => json.encode(new List.from(data.map((x) => x.toJson())));

class ServiceLogsModel {
String vitCasenumber;
String title;
DateTime createdon;
DateTime modifiedon;
String statuscodeODataCommunityDisplayV1FormattedValue;
int statecode;
String incidentid;
bool vitIsfilemandatory;
String customeridContact;
String vitFilesuploadedtosharepoint;
String vitJsondata;
int vitTypeofform;
bool vitReadstatus;

ServiceLogsModel({
this.vitCasenumber,
this.title,
this.createdon,
this.modifiedon,
this.statuscodeODataCommunityDisplayV1FormattedValue,
this.statecode,
this.incidentid,
this.vitIsfilemandatory,
this.customeridContact,
this.vitFilesuploadedtosharepoint,
this.vitJsondata,
this.vitTypeofform,
this.vitReadstatus,
});

factory ServiceLogsModel.fromJson(Map<String, dynamic> json) => new ServiceLogsModel(
vitCasenumber: json["vit_casenumber"],
title: json["title"],
createdon: DateTime.parse(json["createdon"]),
modifiedon: DateTime.parse(json["modifiedon"]),
statuscodeODataCommunityDisplayV1FormattedValue: json["statuscode@OData.Community.Display.V1.FormattedValue"],
statecode: json["statecode"],
incidentid: json["incidentid"],
vitIsfilemandatory: json["vit_isfilemandatory"],
customeridContact: json["customerid_contact"],
vitFilesuploadedtosharepoint: json["vit_filesuploadedtosharepoint"],
vitJsondata: json["vit_jsondata"],
vitTypeofform: json["vit_typeofform"],
vitReadstatus: json["vit_readstatus"],
);

Map<String, dynamic> toJson() => {
"vit_casenumber": vitCasenumber,
"title": title,
"createdon": createdon.toIso8601String(),
"modifiedon": modifiedon.toIso8601String(),
"statuscode@OData.Community.Display.V1.FormattedValue": statuscodeODataCommunityDisplayV1FormattedValue,
"statecode": statecode,
"incidentid": incidentid,
"vit_isfilemandatory": vitIsfilemandatory,
"customerid_contact": customeridContact,
"vit_filesuploadedtosharepoint": vitFilesuploadedtosharepoint,
"vit_jsondata": vitJsondata,
"vit_typeofform": vitTypeofform,
"vit_readstatus": vitReadstatus,
};
}
`

I am getting the response like this

[
{
"vit_casenumber": "CM1902849",
"title": "Request For Reference Letter",
"createdon": "2019-06-27T04:43:44Z",
"modifiedon": "2019-06-27T04:54:03Z",
"statuscode@OData.Community.Display.V1.FormattedValue": "New",
"statecode": 0,
"incidentid": "e7d38720-9698-e911-a855-000d3ae0a7f8",
"vit_isfilemandatory": false,
"customerid_contact": null,
"vit_filesuploadedtosharepoint": null,
"vit_jsondata": null,
"vit_typeofform": 2,
"vit_readstatus": true
},
{
"vit_casenumber": "CM1902848",
"title": "Request For Reference Letter",
"createdon": "2019-06-26T12:53:13Z",
"modifiedon": "2019-06-26T12:53:17Z",
"statuscode@OData.Community.Display.V1.FormattedValue": "New",
"statecode": 0,
"incidentid": "681bb658-1198-e911-a852-000d3ae0b82e",
"vit_isfilemandatory": false,
"customerid_contact": null,
"vit_filesuploadedtosharepoint": null,
"vit_jsondata": null,
"vit_typeofform": 2,
"vit_readstatus": false
}
]

when I am executing this line

json.decode(response.body);

I am getting this error

Unhandled Exception: type 'List' is not a subtype of type 'String'

Please help me to sort out the problem

@joao-rafael
Copy link

Got the same issue while trying to pass a list to the items property of the DorpdownMenu widget.

@Ashbuhrz
Copy link

Ashbuhrz commented Feb 10, 2020

The problem is your fromMap constructor is reading from a Map<String, dynamic>, so I bet that all of the lists in that map are actually List<dynamic> or just dynamic. Try doing this instead:

List<String> likes;

LiveChat.fromMap(Map<String, dynamic> data) {
  likes = data['likes'].cast<String>();
}

can you please help me with this also

     body: Container(
     child: Center(
      child: FutureBuilder(
        future:
            DefaultAssetBundle.of(context).loadString('jsons/data.json'),
        builder: (context, snapshot) {
          if (!snapshot.hasData) {
            return CircularProgressIndicator();
          }
          var myData = jsonDecode(snapshot.data);
          final welcome = welcomeFromJson(myData);

          print(myData.length);
          return ListView.builder(
            itemBuilder: (BuildContext context, int index) {
              return Card(
                  child: ListTile(
                title: Text(welcome[index]
                    .tableMenuList[index]
                    .categoryDishes[index]
                    .dishName),
              ));
            },
            itemCount: myData == null ? 0 : myData.length,
          );
        },
      ),
    ),
  ),

error : type 'List' is not a subtype of type 'String'

@mohit-solankee99
Copy link

mohit-solankee99 commented Feb 24, 2020

@Ashbuhrz You should add mydata in List
with following code

List data;

var myData = jsonDecode(snapshot.data);
data=mydata[''];

and item count will be

itemCount: data == null ? 0 : data.length,

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 12, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 12, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 12, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 13, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 18, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 18, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 18, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 18, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 18, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Jun 18, 2020
zljj0818 pushed a commit to zljj0818/flutter that referenced this issue Jun 22, 2020
* 141ee78 Roll Dart SDK from 2b917f5b6a0e to 0fab083e1c2b (15 revisions) (flutter/engine#18974)

* f5ab179 Call Shell::NotifyLowMemoryWarning on Android Trim and LowMemory events (flutter/engine#18979)

* 4dabac9 Roll Fuchsia Linux SDK from 8AiUM... to ThzHh... (flutter/engine#18976)

* 50cae02 Reland: Add RAII wrapper for EGLSurface (flutter/engine#18977)

* db7f226 Include the memory header as unique_ptr is used in ASCII Trie. (flutter/engine#18978)

* b19a17d Implement an EGL resource context for the Linux shell. (flutter/engine#18918)

* ca26b75 Make Linux shell plugin constructor descriptions consistent (flutter/engine#18940)

* efd1452 Roll Skia from 9c401e7e1ace to f69e40841eb9 (11 revisions) (flutter/engine#18983)

* e5845af Put JNI functions under an interface (flutter/engine#18903)

* 1ddc6e1 Call destructor and fix check (flutter/engine#18985)

* 7f71f1d Roll Fuchsia Mac SDK from oWhyp... to gAD3P... (flutter/engine#18982)

* 74291b7 Roll Dart SDK from 0fab083e1c2b to e62b89c56d01 (10 revisions) (flutter/engine#18987)

* 2739bbf [web] Provide a hook to disable location strategy (flutter/engine#18969)

* 336d000 Roll Skia from f69e40841eb9 to 553496b66f12 (2 revisions) (flutter/engine#18992)

* b82769b Roll Skia from 553496b66f12 to 0ad37b87549b (2 revisions) (flutter/engine#18993)

* f5ca58b Roll Dart SDK from e62b89c56d01 to b0d2b97d2cd7 (4 revisions) (flutter/engine#18994)

* 2a82a08 [dart] Account for compiler api change (flutter/engine#19002)

* 369e0a9 Add ui_benchmarks (flutter/engine#18945)

* a0a92d6 Roll Skia from 0ad37b87549b to de175abede4d (1 revision) (flutter/engine#18995)

* cea5a9c Roll Dart SDK from b0d2b97d2cd7 to f043f9e5f6ea (6 revisions) (flutter/engine#18997)

* d417772 Roll Fuchsia Mac SDK from gAD3P... to Wj0yo... (flutter/engine#19001)

* 4538622 Roll Skia from de175abede4d to 32d5cfa1f35e (15 revisions) (flutter/engine#19005)

* 71fce02 Fix shift-tab not working by adding more GTK->GLFW key mappings. (flutter/engine#18988)

* 5ddc122 Fix inverted check in creating resource surface (flutter/engine#18989)

* 87d8888 Show warning if method response errors occur and error not handled. (flutter/engine#18946)

* 5171fbd Roll Skia from 32d5cfa1f35e to 21bbfc6c2dfe (5 revisions) (flutter/engine#19006)

* 4bd6aea Always send key events, even if they're used for text input. (flutter/engine#18991)

* 9f898e9 Don't process key events when the text input is not requested (flutter/engine#18990)

* 48d7091 Roll buildroot for Windows warning update (flutter/engine#19000)

* 5f37029 Roll Dart SDK from f043f9e5f6ea to f0ea02bc51f8 (22 revisions) (flutter/engine#19010)

* ac809b4 onBeginFrame JNI (flutter/engine#18866)

* e1c622b Make SKSL caching test work on Fuchsia on arm64 (flutter/engine#18572)

* 2651beb Exit before pushing a trace event when layer tree holder is empty (flutter/engine#19008)

* acf048b Remove log added for local testing (flutter/engine#19012)

* 1f3aa23 Roll Dart SDK from f0ea02bc51f8 to 0b64f5488965 (9 revisions) (flutter/engine#19013)

* 8dcc95d Roll Fuchsia Mac SDK from Wj0yo... to gR0Zc... (flutter/engine#19015)

* f6455fa Roll Dart SDK from 0b64f5488965 to 50836c171e91 (4 revisions) (flutter/engine#19017)

* b2fea9d Roll Skia from 21bbfc6c2dfe to 30212b7941d6 (6 revisions) (flutter/engine#19009)

* 0065646 Roll Skia from 30212b7941d6 to 3d6bf04366f6 (17 revisions) (flutter/engine#19020)

* 0a852d8 Revert "Call Shell::NotifyLowMemoryWarning on Android Trim and LowMemory events (flutter#18979)" (flutter/engine#19023)

* 194acdf apply null safety syntax to mobile dart:ui (flutter/engine#18933)

* b0a0e0e Roll Skia from 3d6bf04366f6 to 637838d20abd (2 revisions) (flutter/engine#19021)

* be499ab Roll Fuchsia Mac SDK from gR0Zc... to H-uAk... (flutter/engine#19022)

* 8c24c41 Roll Skia from 637838d20abd to ac16760df463 (1 revision) (flutter/engine#19025)

* 7cb7003 onEndFrame JNI (flutter/engine#18867)

* e3fdb23 [fuchsia] Add ability to configure separate data and asset dirs (flutter/engine#18858)

* 983b6e1 Call Shell::NotifyLowMemory when backgrounded/memory pressure occurs on Android (flutter/engine#19026)

* f7d241f Wire up channel for restoration data (flutter/engine#18042)

* e84d497 Fix hit testing logic in fuchsia a11y (flutter/engine#19029)

* 801559a Revert to last-known-good-rev of Dart SDK (flutter/engine#19031)
@mamedshahmaliyev
Copy link

just use: (yourlist as List).map((e) => e.toString()).toList();

@ella97
Copy link

ella97 commented Sep 1, 2020

class Product {
  int id;
  String name;
  String photo;
  int price;
  int discount;
  String productDetail;
  int quantity;

  toMap() {
    var map = Map<String, dynamic>();
    map['productId'] = id;
    map['productName'] = name;
    map['productPhoto'] = photo;
    map['productPrice'] = price;
    map['productDiscount'] = discount;
    map['productQuantity'] = quantity;
    return map;
  }

  
}
type 'List<dynamic>' is not a subtype of type 'List<String>'

please help

mingwandroid pushed a commit to mingwandroid/flutter that referenced this issue Sep 6, 2020
* 141ee78 Roll Dart SDK from 2b917f5b6a0e to 0fab083e1c2b (15 revisions) (flutter/engine#18974)

* f5ab179 Call Shell::NotifyLowMemoryWarning on Android Trim and LowMemory events (flutter/engine#18979)

* 4dabac9 Roll Fuchsia Linux SDK from 8AiUM... to ThzHh... (flutter/engine#18976)

* 50cae02 Reland: Add RAII wrapper for EGLSurface (flutter/engine#18977)

* db7f226 Include the memory header as unique_ptr is used in ASCII Trie. (flutter/engine#18978)

* b19a17d Implement an EGL resource context for the Linux shell. (flutter/engine#18918)

* ca26b75 Make Linux shell plugin constructor descriptions consistent (flutter/engine#18940)

* efd1452 Roll Skia from 9c401e7e1ace to f69e40841eb9 (11 revisions) (flutter/engine#18983)

* e5845af Put JNI functions under an interface (flutter/engine#18903)

* 1ddc6e1 Call destructor and fix check (flutter/engine#18985)

* 7f71f1d Roll Fuchsia Mac SDK from oWhyp... to gAD3P... (flutter/engine#18982)

* 74291b7 Roll Dart SDK from 0fab083e1c2b to e62b89c56d01 (10 revisions) (flutter/engine#18987)

* 2739bbf [web] Provide a hook to disable location strategy (flutter/engine#18969)

* 336d000 Roll Skia from f69e40841eb9 to 553496b66f12 (2 revisions) (flutter/engine#18992)

* b82769b Roll Skia from 553496b66f12 to 0ad37b87549b (2 revisions) (flutter/engine#18993)

* f5ca58b Roll Dart SDK from e62b89c56d01 to b0d2b97d2cd7 (4 revisions) (flutter/engine#18994)

* 2a82a08 [dart] Account for compiler api change (flutter/engine#19002)

* 369e0a9 Add ui_benchmarks (flutter/engine#18945)

* a0a92d6 Roll Skia from 0ad37b87549b to de175abede4d (1 revision) (flutter/engine#18995)

* cea5a9c Roll Dart SDK from b0d2b97d2cd7 to f043f9e5f6ea (6 revisions) (flutter/engine#18997)

* d417772 Roll Fuchsia Mac SDK from gAD3P... to Wj0yo... (flutter/engine#19001)

* 4538622 Roll Skia from de175abede4d to 32d5cfa1f35e (15 revisions) (flutter/engine#19005)

* 71fce02 Fix shift-tab not working by adding more GTK->GLFW key mappings. (flutter/engine#18988)

* 5ddc122 Fix inverted check in creating resource surface (flutter/engine#18989)

* 87d8888 Show warning if method response errors occur and error not handled. (flutter/engine#18946)

* 5171fbd Roll Skia from 32d5cfa1f35e to 21bbfc6c2dfe (5 revisions) (flutter/engine#19006)

* 4bd6aea Always send key events, even if they're used for text input. (flutter/engine#18991)

* 9f898e9 Don't process key events when the text input is not requested (flutter/engine#18990)

* 48d7091 Roll buildroot for Windows warning update (flutter/engine#19000)

* 5f37029 Roll Dart SDK from f043f9e5f6ea to f0ea02bc51f8 (22 revisions) (flutter/engine#19010)

* ac809b4 onBeginFrame JNI (flutter/engine#18866)

* e1c622b Make SKSL caching test work on Fuchsia on arm64 (flutter/engine#18572)

* 2651beb Exit before pushing a trace event when layer tree holder is empty (flutter/engine#19008)

* acf048b Remove log added for local testing (flutter/engine#19012)

* 1f3aa23 Roll Dart SDK from f0ea02bc51f8 to 0b64f5488965 (9 revisions) (flutter/engine#19013)

* 8dcc95d Roll Fuchsia Mac SDK from Wj0yo... to gR0Zc... (flutter/engine#19015)

* f6455fa Roll Dart SDK from 0b64f5488965 to 50836c171e91 (4 revisions) (flutter/engine#19017)

* b2fea9d Roll Skia from 21bbfc6c2dfe to 30212b7941d6 (6 revisions) (flutter/engine#19009)

* 0065646 Roll Skia from 30212b7941d6 to 3d6bf04366f6 (17 revisions) (flutter/engine#19020)

* 0a852d8 Revert "Call Shell::NotifyLowMemoryWarning on Android Trim and LowMemory events (flutter#18979)" (flutter/engine#19023)

* 194acdf apply null safety syntax to mobile dart:ui (flutter/engine#18933)

* b0a0e0e Roll Skia from 3d6bf04366f6 to 637838d20abd (2 revisions) (flutter/engine#19021)

* be499ab Roll Fuchsia Mac SDK from gR0Zc... to H-uAk... (flutter/engine#19022)

* 8c24c41 Roll Skia from 637838d20abd to ac16760df463 (1 revision) (flutter/engine#19025)

* 7cb7003 onEndFrame JNI (flutter/engine#18867)

* e3fdb23 [fuchsia] Add ability to configure separate data and asset dirs (flutter/engine#18858)

* 983b6e1 Call Shell::NotifyLowMemory when backgrounded/memory pressure occurs on Android (flutter/engine#19026)

* f7d241f Wire up channel for restoration data (flutter/engine#18042)

* e84d497 Fix hit testing logic in fuchsia a11y (flutter/engine#19029)

* 801559a Revert to last-known-good-rev of Dart SDK (flutter/engine#19031)
@Santosh1432
Copy link

My model class is like this

`import 'dart:convert';

List serviceLogsModelFromJson(String str) => new List.from(json.decode(str).map((x) => ServiceLogsModel.fromJson(x)));

String serviceLogsModelToJson(List data) => json.encode(new List.from(data.map((x) => x.toJson())));

class ServiceLogsModel {
String vitCasenumber;
String title;
DateTime createdon;
DateTime modifiedon;
String statuscodeODataCommunityDisplayV1FormattedValue;
int statecode;
String incidentid;
bool vitIsfilemandatory;
String customeridContact;
String vitFilesuploadedtosharepoint;
String vitJsondata;
int vitTypeofform;
bool vitReadstatus;

ServiceLogsModel({
this.vitCasenumber,
this.title,
this.createdon,
this.modifiedon,
this.statuscodeODataCommunityDisplayV1FormattedValue,
this.statecode,
this.incidentid,
this.vitIsfilemandatory,
this.customeridContact,
this.vitFilesuploadedtosharepoint,
this.vitJsondata,
this.vitTypeofform,
this.vitReadstatus,
});

factory ServiceLogsModel.fromJson(Map<String, dynamic> json) => new ServiceLogsModel(
vitCasenumber: json["vit_casenumber"],
title: json["title"],
createdon: DateTime.parse(json["createdon"]),
modifiedon: DateTime.parse(json["modifiedon"]),
statuscodeODataCommunityDisplayV1FormattedValue: json["statuscode@OData.Community.Display.V1.FormattedValue"],
statecode: json["statecode"],
incidentid: json["incidentid"],
vitIsfilemandatory: json["vit_isfilemandatory"],
customeridContact: json["customerid_contact"],
vitFilesuploadedtosharepoint: json["vit_filesuploadedtosharepoint"],
vitJsondata: json["vit_jsondata"],
vitTypeofform: json["vit_typeofform"],
vitReadstatus: json["vit_readstatus"],
);

Map<String, dynamic> toJson() => {
"vit_casenumber": vitCasenumber,
"title": title,
"createdon": createdon.toIso8601String(),
"modifiedon": modifiedon.toIso8601String(),
"statuscode@OData.Community.Display.V1.FormattedValue": statuscodeODataCommunityDisplayV1FormattedValue,
"statecode": statecode,
"incidentid": incidentid,
"vit_isfilemandatory": vitIsfilemandatory,
"customerid_contact": customeridContact,
"vit_filesuploadedtosharepoint": vitFilesuploadedtosharepoint,
"vit_jsondata": vitJsondata,
"vit_typeofform": vitTypeofform,
"vit_readstatus": vitReadstatus,
};
}
`

I am getting the response like this

[
{
"vit_casenumber": "CM1902849",
"title": "Request For Reference Letter",
"createdon": "2019-06-27T04:43:44Z",
"modifiedon": "2019-06-27T04:54:03Z",
"statuscode@OData.Community.Display.V1.FormattedValue": "New",
"statecode": 0,
"incidentid": "e7d38720-9698-e911-a855-000d3ae0a7f8",
"vit_isfilemandatory": false,
"customerid_contact": null,
"vit_filesuploadedtosharepoint": null,
"vit_jsondata": null,
"vit_typeofform": 2,
"vit_readstatus": true
},
{
"vit_casenumber": "CM1902848",
"title": "Request For Reference Letter",
"createdon": "2019-06-26T12:53:13Z",
"modifiedon": "2019-06-26T12:53:17Z",
"statuscode@OData.Community.Display.V1.FormattedValue": "New",
"statecode": 0,
"incidentid": "681bb658-1198-e911-a852-000d3ae0b82e",
"vit_isfilemandatory": false,
"customerid_contact": null,
"vit_filesuploadedtosharepoint": null,
"vit_jsondata": null,
"vit_typeofform": 2,
"vit_readstatus": false
}
]

when I am executing this line

json.decode(response.body);

I am getting this error

Unhandled Exception: type 'List' is not a subtype of type 'String'

Please help me to sort out the problem

Hi Vivek, Can u Please send the solution for this Error

@exeptionerror

This comment was marked as spam.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
d: stackoverflow Good question for Stack Overflow
Projects
None yet
Development

No branches or pull requests

15 participants