我有这样的事情:
class MyClass
{
static void DoSomething(arg1, arg2){...}
}
Run Code Online (Sandbox Code Playgroud)
通过反射,我能够获得此类的ClassMirror.从这一点开始,我将如何获得具体的静态函数,以便我可以调用它.
请注意,我尝试使用:
ObjectMirror.invoke('DoSomething', [arg1, arg2]);
Run Code Online (Sandbox Code Playgroud)
最初似乎工作,但它不支持传递复杂类型作为参数,这个静态函数需要一个复杂的类型作为其参数之一.
理想情况下,我想获得表示静态方法的'Function'对象,以便我可以直接调用它.
由于 pub 使用我的身份进行发布,我将如何将控制权转移给其他人,但仍允许他们将版本发布到同一个项目?也许这是微不足道的;我从来没有尝试过。
如果我这样做,例如:
FutureBuilder(
initialData: null,
future: compute(expensiveParsingOperation, data),
builder: (context, snapshot) {
if(!snapshot.hasData){
// This doesn't spin (frozen). The entire UI is janked until the expensive operation future completes.
CircularProgressIndicator();
}else {
Container();
}
});
Run Code Online (Sandbox Code Playgroud)
我希望上述内容将expensiveParsingOperation函数发送给网络工作者或其他东西,而不是卡住主线程,但这不是我观察中发生的情况。