popupWidget function

Widget popupWidget(
  1. GlobalKey<State<StatefulWidget>> _popupKey,
  2. ComboData2 data,
  3. dynamic setValue(
    1. String
    ),
  4. String stringSearchText, {
  5. dynamic selectMany = false,
})

Implementation

Widget popupWidget(GlobalKey _popupKey, ComboData2 data, Function(String) setValue,
    String stringSearchText,
    {selectMany = false}){

  _stringSearchText = stringSearchText;

  if (!_isPresent(_popupKey))
    _popups.add(_PopupWindow(_popupKey, data: data, setValue: setValue, selectMany: selectMany));

  _PopupWindow current = _getCurrent(_popupKey);
  current.setValue = setValue;
  current.data = data;
  //
  String _text = "";
  String _email = "";
  if (current.selectMany){
    for (var item in data.data){
      if (item.checkSelected) {
        if (_text.isNotEmpty)
          _text += " | ";
        _text += item.text;
      }
    }
  }
  if (!current.selectMany || _text.isEmpty) {
    for (var item in data.data)
      if (item.id == data.value) {
        _text = item.text;
        _email = item.email;
      }
  }

  return Container(
      key: _popupKey,
      height: 40,
      decoration: BoxDecoration(
        // color: widget.backgroundColor,
        borderRadius: BorderRadius.circular(aTheme.radius),
        border: Border.all(
          color: Colors.grey,
          width: 1.0,
        ),
      ),
      child: InkWell(
        onTap: (){
          _openListPopup(current);
        },
        child: Container(
          margin: EdgeInsets.only(left: 20, right: 20),
          child: Row(
          children: [
            Expanded(child: Row(
              children: [
                Expanded(child: Text(_text, style: aTheme.style14W400, overflow: TextOverflow.ellipsis,)),
                SizedBox(width: 10,),
                Text(_email, style: aTheme.style12W600Grey,),
              ],
            )),
            Icon(Icons.arrow_downward_sharp, color: Colors.black, size: 20,)
          ],
        )),
      ),
  );
}