static Object _bindLoopVariable()

in packages/rfw/lib/src/flutter/runtime.dart [460:526]


  static Object _bindLoopVariable(Object node, Object argument, int depth) {
    if (node is DynamicMap) {
      return node.map<String, Object?>(
        (String name, Object? value) => MapEntry<String, Object?>(name, _bindLoopVariable(value!, argument, depth)),
      );
    }
    if (node is DynamicList) {
      return List<Object>.generate(
        node.length,
        (int index) => _bindLoopVariable(node[index]!, argument, depth),
        growable: false,
      );
    }
    if (node is Loop) {
      return Loop(_bindLoopVariable(node.input, argument, depth), _bindLoopVariable(node.output, argument, depth + 1));
    }
    if (node is Switch) {
      return Switch(
        _bindLoopVariable(node.input, argument, depth),
        node.outputs.map<Object?, Object>(
          (Object? key, Object value) => MapEntry<Object?, Object>(
            key == null ? null : _bindLoopVariable(key, argument, depth),
            _bindLoopVariable(value, argument, depth),
          ),
        )
      );
    }
    if (node is _CurriedLocalWidget) {
      return _CurriedLocalWidget(
        node.fullName,
        node.child,
        _bindLoopVariable(node.arguments, argument, depth) as DynamicMap,
      );
    }
    if (node is _CurriedRemoteWidget) {
      return _CurriedRemoteWidget(
        node.fullName,
        _bindLoopVariable(node.child, argument, depth) as _CurriedWidget,
        _bindLoopVariable(node.arguments, argument, depth) as DynamicMap,
        node.initialState,
      );
    }
    if (node is _CurriedSwitch) {
      return _CurriedSwitch(
        node.fullName,
        _bindLoopVariable(node.root, argument, depth) as Switch,
        _bindLoopVariable(node.arguments, argument, depth) as DynamicMap,
        node.initialState,
      );
    }
    if (node is LoopReference) {
      if (node.loop == depth) {
        return node.bind(argument);
      }
      return node;
    }
    if (node is BoundArgsReference) {
      return BoundArgsReference(_bindLoopVariable(node.arguments, argument, depth), node.parts);
    }
    if (node is EventHandler) {
      return EventHandler(node.eventName, _bindLoopVariable(node.eventArguments, argument, depth) as DynamicMap);
    }
    if (node is SetStateHandler) {
      return SetStateHandler(node.stateReference, _bindLoopVariable(node.value, argument, depth));
    }
    return node;
  }