I've run into an error I can't quite figure out. I'm calling the service from the action and setting a new redux state with th response. However, I get the following error:


The argument type 'List<Chat> (C:\flutter\bin\cache\pkg\sky_engine\lib\core\list.dart)' can't be assigned to the parameter type 'List<Chat> (C:\flutter\bin\cache\pkg\sky_engine\lib\core\list.dart)'.


class GetChatRequest {}

class GetChatSuccess {
  final List<Chat> history;


class GetChatFailure {
  final String error;


final Function getLastChatMessages = () {
  return (Store<AppState> store) {
    var chatService = new ChatService(store);

    store.dispatch(new GetChatRequest());
    chatService.getLast50Messages().then((history) {
      store.dispatch(new GetChatSuccess(history));


Future<List<Chat>> getLast50Messages() async {
    final response = await webClient.get('xxxx');
    return response['data'].map<Chat>((e) => new Chat.fromJSON(e)).toList();

Solution 1: Günter Zöchbauer


store.dispatch(new GetChatSuccess(history));


store.dispatch(new GetChatSuccess(List<Chat>.from(history)));

to get a properly typed list.

history is a List<dynamic> that contains only Chat elements, but the list has still the generic type dynamic. To create a properly typed List<Chat> create a new list with that type and fill it with the elements from history.

See also https://api.dartlang.org/stable/2.1.0/dart-core/List/List.from.html