dart 泛型扩展类型问题..方法<T 扩展动态>

dev*_*uaz 5 generics types function dart

我在这里遇到了一个小问题..我正在尝试编写一个从动态扩展的 T 类型的泛型方法,但是当我调用未定义的方法时,其中会显示错误。

代码

List<T> toListOf<T extends dynamic>(dynamic data, String key) {
  return List<T>.from(data[key]?.map((x) => T.fromMap(x)));
}
Run Code Online (Sandbox Code Playgroud)

图像

在此输入图像描述

错误

The method 'fromMap' isn't defined for the type 'Type'.

Try correcting the name to the name of an existing method, or defining a method named 'fromMap'
Run Code Online (Sandbox Code Playgroud)

有什么解决办法吗?