setData method

void setData()

Implementation

void setData()
{
  // value is not in data?
  if (!_containsOption())
  {
    dynamic value;

    if(options.isNotEmpty){
      value = options[0].value;
    }

    // set to first entry if no datasource
    if (datasource == null)
    {

      // if we set value to itself it will cause an infinite loop
      if (this.value != value)
      {
      this.value = value;
      }

    }

    // set to first entry after data has been returned
    else if (options.isNotEmpty)
    {
      // if we set value to itself it will cause an infinite loop
      if (this.value != value) this.value = value;
      //tell the form that I have set my own value outside of a user choice;

    }
  }

  dynamic data;
  for (var option in options) {
    if (option.value == value)
    {
      data = option.data;
      label = option.labelValue;
    }
  }
  this.data = data;
}