BsSelectBoxResponse.createFromJson constructor

BsSelectBoxResponse.createFromJson(
  1. List map, {
  2. BsSetOptionValue? value,
  3. BsRenderText? renderText,
  4. BsSetOptionValue? other,
})

handle response from api with default setting

In default setting this function will put value index for value option, and text index for text option from response data

Implementation

factory BsSelectBoxResponse.createFromJson(List map, {BsSetOptionValue? value, BsRenderText? renderText, BsSetOptionValue? other}) {
  return BsSelectBoxResponse(
    options: map.map((e) {
      return BsSelectBoxOption(
        value: value == null ? e['value'] : value(e),
        text: renderText == null ? Text(e['text']) : renderText(e),
        other: other == null ? e : other(e),
      );
  }).toList());
}