rebindField method

void rebindField(
  1. String fieldName,
  2. FlutterWidgetBinder binder
)

Rebinds a field to use a different widget binder.

This method allows changing how a field is rendered and bound to widgets at runtime. It preserves the current value of the field while switching to the new binding.

Implementation

void rebindField(String fieldName, FlutterWidgetBinder binder) {
  final index = _fieldNames.indexOf(fieldName);
  if (index == -1) {
    throw ArgumentError("No field with name $fieldName");
  }
  var field = fields[index];
  final currentValue = field.getValue();
  final controller = binder.createBindingController(this, field.bindingContext);
  factories[index] = binder;
  fields[index] = controller;
  controller.setValue(currentValue);
}