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

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):
I/flutter (20672): When the exception was thrown, this was the stack:
I/flutter (20672): #0<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
24 Answers

✔️Accepted Answer

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>();

Other Answers:

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.

@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>

Related Issues:

flutter Multiple commands produce '/build/ios/Debug-iphonesimulator/
I was able to fix it by opening the Runner workspace project in Xcode 10 Then navigate to File ...
flutter App Store iOS submission fails: The bundle does not support the minimum OS Version specified in the Info.plist
After doing a flutter clean changing MinimumOSVersion (inside /ios/Flutter/AppframeworkInfo.plist) t...
flutter '' has different version for the compile (26.1.0) and runtime (27.0.1) classpath
is like this i receive an error when i run flutter run My file is: flutter doctor: ...
flutter Why does my text not wrap?
You have to wrap Column in a flexible Without flexible the column's width is not constrained to the ...
flutter Unexpected top padding in ListView put inside scaffold with no appBar
Yeah this is intentional If you put a widget before the ListView you should wrap the ListView with a...
flutter Missing xcode dependency: Python module "six"
try python2.x -m pip install six by @humblerookie's suggest or brew reinstall python@2 pip install s...
flutter flutter messaging: set the notification icon
Hey guys I fought with this for the better part of a day For some strange reason there are no tutori...
flutter Issue with cloud_firestore - Cannot fit requested classes in a single dex file.
As a workaround you can try enabling mutlidex for Android App by following Enable multidex for apps ...
flutter D8: Program type already present: io.flutter.BuildConfig
@smrucv I received the same error but after flutter clean and flutter packages get everything works ...
flutter Introduction of characters package causes crash on flutter run for preexisting Flutter applications
In my case I resolved the issue with flutter clean After e0ed12c I get this error when building: @ju...
flutter Making Network http error SocketException: Failed host lookup
@hoc081098 Double-check / make sure you have <uses-permission android:name=android.permission.INTERN...
flutter Support inlining Android/iOS views
iOS view embedding support has landed on master This is still just a preview There are multiple open...
flutter ✗ Android license status unknown.
Hi everyone Steps to Reproduce Please tell us what you were doing and what went wrong If you are run...
flutter idevice_id cannot run on catalina
When you're developing on Catalina Steps to Reproduce Run flutter doctor on macOS Catalina I get the...
flutter type 'List<dynamic>' is not a subtype of type 'List<String>'
The problem is your fromMap constructor is reading from a Map<String dynamic> ...
flutter TextField is hidden by keyboard inside of a Modal Bottom Sheet
This may not work for all situations but I have a modalBottomSheet that contains only a TextField ...
flutter Dismissing keyboard programatically
This is a better way as it also clears the focus: FocusScope.of(context).requestFocus(new FocusNode(...
flutter How to solve: Android license status unknown and also Android sdkmanager tool not found? Tried everything(as i think)
The answer is here Uncheck Hide Obsolete Packages and you'll see Android SDK Tools (Obsolete) 26.1.1...
flutter MissingPluginException: No implementation found for method
@mravn-google Yeah turned out I had to quit the flutter run process and start it up again Just a ful...
flutter firebase_auth: ^0.8.0+1 crashes on Android
Here i put this in file: android/ and changed targetSdkVersion to 28 and it worked...
flutter Android sdkmanager tool not found (C:...\Local\Android\sdk\tools\bin\sdkmanager)
This worked for me: open Android Studio's SDK Manager go to the Android SDK tab under SDK Tools ...
flutter 1.22.2 - Flutter plugin not installed; this adds Flutter specific functionality.
Hey @bhanuka96 try this line of code How do I fix this android plugin error? This error is being com...
flutter [ios][release] GeneratedPluginRegistrant.m Module not found
I may have found the answer from this comment: #21989 (comment) Seems like by opening up the project...
flutter [App.framework] Linked and embedded framework 'App.framework' was built for iOS/iOS Simulator
Does rm -rf ios/Flutter/App.framework get you unstuck? SOLUTION @jmagman has written an article on h...
flutter Bad state: Future already completed
I had the same issue.. The problem was the same that @soaresgabriel said but I was not navigating di...
flutter Execution failed for task ':app:compileFlutterBuildDebug' Issue
Hi @Ramihtet your logs show a different flutter version; could you please run flutter channel stable...
flutter Unable to load Asset - wrong indentation in pubspec.yaml
Is your assets key underneath a flutter: key as well? ...
flutter Flutter 1.12.13+hotfix.5: Flutter Run: The shrinker may have failed to optimize the Java bytecode.
The plugin seems to work correctly after adding minifyEnabled true as shown above in app-level build...
flutter Create iOS IPA from command line
This is what I ended up using as a complete release script ready for uploading to the Play Store/App...
flutter FutureBuilder rebuilds unnecessarily when we long press on FAB button or appBar UI.
Hello I believe the problem here is that didUpdateWidget of the FutureBuilder state is being called ...
flutter LinearGradient stops/colors properties as named parameters fail
Ah nice I'm on master but also had to flutter clean and then restart VS Code and now it has gone awa...
flutter gradle initializing taking forever
MacOS Android Studio 3.0.1 Try to install gradle manually (
flutter invalid text selection: TextSelection with TextEditingController
Can also confirm clearing text in single textfield throws exactly same exception FocusScope.of(conte...
flutter Bad state: Unexpected diagnostics:
Was able to fixed After add this in pubspec.yaml the error gone Thanks #62996 and #62240 ...
flutter [cloud_firestore 0.12.6] CloudFirestorePlugin.m:6:9: fatal error: 'UserAgent.h' file not found
I tried this • flutter clean • Clean Build Folder from Xcode • delete Podfile.lock But this didn't w...
flutter How to run on iOS simulator?
Make sure you have run sudo xcode-select --switch /Applications/ sudo xc...
flutter flutter run failed due to 'Permission denied' when replacing signature of 'Flutter.framework'
After investigating i think the root cause was the will mark the files under Flutte...
flutter [firebase_crashlytics] Gradle build failed
@TheVinhLuong Had the same issue your workaround worked thanks! @livingstonex If you've followed ins...
flutter "Minimum supported Gradle version is 5.4.1. Current version is 4.10.2."
Ran across this problem myself If anyone comes across this from google Steps to Reproduce Not much i...
flutter Analyzer 0.39.15 seems to break build_runner or json_serializable
For anyone searching here you can set the override for now inside your pubspec.yaml: As explained in...
flutter Execution failed for task ':firebase_auth:compileDebugJavaWithJavac'.
This is what helped me: Go to android/app/build.gradle file and change compileSdkVersion and targetS...
flutter flutter doctor returns [Unhandled exception: Exception: idevice_id returned an error]
running sudo pkill usbmuxd worked for me on Mac OSX I ran the flutter doctor there were some brew in...
flutter "-bash: webdev: command not found"
This worked for me: I am trying to get the web flutter running Updated the bash_profile with export ...
flutter [Error: Could not resolve the package 'characters' in 'package:characters/characters.dart'.] after enabling web
Hi @gamepro110 new project follow steps on this link for the SETUP only trying to build for android ...
flutter type 'Color' is not a subtype of type 'MaterialColor' of 'primarySwatch' where Color is from dart:ui
Looks like this is working as intended: primarySwatch takes a ColorSwatch [which MaterialColor exten...
flutter TextFormField Android "Failed assertion: 'initialValue == null || controller == null': is not true." Despite controller being null in debug.
I just had this problem For anyone else coming along check if you have passed both initialValue and ...
flutter AAPT: error: resource android:attr/fontVariationSettings not found after Flutter Upgrade
Setting compileSdkVersion 28 in app/build.gradle fixed the issue for me. My flutter application used...