icemanbsi / searchable_dropdown

MIT License
107 stars 162 forks source link

Failed assertion: line 358 pos 16: 'items != null': is not true. #73

Open pkmangukiya opened 4 years ago

pkmangukiya commented 4 years ago

@lcuis :- If you know anything about this, let us know quickly.

When i waiting for api response List<DropdownMenuItem> stateDropdownItems;

 @override
  void initState() {
    getState(param);
    super.initState();
  }

void getState(Map param) {
   ApiManager.instance.postAPICall(BASE_URL + get_city, param).then(
      (value) async {
        stateList = (jsonDecode(value) as List<dynamic>)
            .map<StateModel>((e) => StateModel(e['name'], e['city_id']))
            .toList();
        stateDropdownItems = stateList
            .map<DropdownMenuItem<StateModel>>((e) => DropdownMenuItem(
          child: Text(e.name),
          value: e,
        )) .toList();
     }, onError: (error) {
     });
 }

SearchableDropdown(
    items: stateDropdownItems,
    hint: Text('Select a State'),
    searchHint: new Text(
           'Search a State',
      ),
    onChanged: (value) {
         setState(() {
             selectedState = value;
         });
     },
  isExpanded: true,
)