ethanblake4/dart_eval

Is is possible to return a function from bridge class method??

Closed this issue · 2 comments

So, I have bridge class inside I have method called load that returns a load object which is a wrapper class inside of it I have a field called loadMoreData which is of type void function(String) this returns Future object.

Now, can i return this class and invoke the function.
I tried it and it didn't work so thought I might be doing something wrong.

It should be possible. Depending on how it is invoked you will either have to use $Function or $Closure so I would try them both. I'd need to see an example of the code to give more specific advice.

Closing this because it is possible.

static const __$static$method$lazy = $Function(_$static$method$lazy);
  static $Value? _$static$method$lazy(
      Runtime runtime, $Value? target, List<$Value?> args) {
    final builder = args[0] as EvalCallable;
    final $result = Movie.lazy(
      () => (builder.call(runtime, null, [])?.$value as Future)
          .then((value) => value as Movie),
    );
    return $LazyContent.wrap($result);
  }