dispatchFunction method

  1. @override
void dispatchFunction(
  1. TextInputRenderViewModel viewModel,
  2. String functionName,
  3. VoltronArray array, {
  4. Promise? promise,
})
override

Implementation

@override
void dispatchFunction(TextInputRenderViewModel viewModel, String functionName, VoltronArray array,
    {Promise? promise}) {
  switch (functionName) {
    case kFuncSetValue:
      var value = array.getString(0);
      if (value != null) {
        int? pos = array.get<int>(1) ?? value.length;
        LogUtils.i("text_input", "js set value: $value, $pos");
        viewModel.dispatcher.jsSetValue(array.getString(0), pos);
      }
      break;
    case kFuncClear:
      viewModel.dispatcher.jsSetValue("", 0);
      break;
    case kFuncFocus:
      viewModel.focus();
      break;
    case kFuncDismiss:
      viewModel.dismiss();
      break;
    case kFuncBlur:
      viewModel.blur();
      break;
    case kFuncGetValue:
      if (promise != null) {
        var resultMap = viewModel.dispatcher.jsGetValue();
        promise.resolve(resultMap);
      }
      break;
  }
}