I'm trying to use the new (recommended) approach to platform channels Pigeon https://pub.dev/packages/pigeon I'm trying to get a list of items but pigeon doesn't allow for that currently you have to wrap it up in another class see https://github.com/flutter/flutter/issues/66446, but when I do this the list I get is of type dynamic not of the type of the object I want here is my config stripped down for brevity and privacy lol, first my messages.dart file
class Key {
String displayName;
String description;
}
class Keys {
List<VirtualKey> virtualKeys;
}
after running the code generator (again stripped down)
flutter pub run pigeon \
--input pigeons/messages.dart \
--dart_out lib/messages.dart \
--objc_header_out ios/Classes/messages.h \
--objc_source_out ios/Classes/messages.m \
--objc_prefix FLT \
--java_out myApp/pigeon_plugin/Messages.java \
--java_package myApp.pigeon_plugin"
I have this generated
class Keys {
List keys;
// ignore: unused_element
Map<dynamic, dynamic> _toMap() {
final Map<dynamic, dynamic> pigeonMap = <dynamic, dynamic>{};
pigeonMap['keys'] = keys;
return pigeonMap;
}
// ignore: unused_element
static Keys _fromMap(Map<dynamic, dynamic> pigeonMap) {
final Keys result = Keys();
result.keys = pigeonMap['keys'];
return result;
}
}
method that returns this class wrapped in an array list (pidgeon issue https://github.com/flutter/flutter/issues/66453) again sorry for any mistakes trying to edit it for privacy concerns
override fun getKeys(): Messages.Keys {
return Messages.Keys().apply {
this.keys = arrayListOf(getAllKeys())
}
}
fun getAllKeys(): List<Key> {
return KeyManager().allKeys
}
So given all this it should give me a Keys object which holds a list of Key but instead when I try to use it I get a Keys object with a list of dynamic see image below, is this expected behaviour or is there a way to fix this? many thanks
