title: Flutter - dropdown_search - Display items read from JSON array via API Endpoint
body: <p>I am trying to create a drop-down searchable widget using the <a href="https://pub.dev/packages/dropdown_search" rel="nofollow noreferrer">dropdown_search: ^2.0.1</a> package.<br></p>
  <p>I am referring to their example code where by I hit an API endpoint to populate the items in drop-down searchable widget. <a href="https://pub.dev/packages/dropdown_search#endpoint-implementation-using-dio-packagehttpspubdevpackagesdio" rel="nofollow noreferrer">Link</a></p>
  <p>I created model taking their UserModel as reference. <a href="https://pub.dev/packages/dropdown_search#attention" rel="nofollow noreferrer">Link</a></p>
  <p>I am getting the following error :</p>
  <pre><code>The return type 'List&lt;ProductCodeModel&gt;' isn't a 'Future&lt;List&lt;String&gt;&gt;', as required by the closure's context.
  </code></pre>
  <p>I get that it is expecting <code>List&lt;String&gt;</code> but I am unsure how to convert <code>List&lt;ProductCodeModel&gt;</code> to <code>List&lt;String&gt;</code></p>
  <p>Code :</p>
  <pre><code>DropdownSearch&lt;String&gt;(
      mode: Mode.MENU,
      showSelectedItems: true,
      showSearchBox: true,
      dropdownSearchDecoration: const InputDecoration(
        label: Text('Product Code'),
        focusColor: Colors.blue,
        border: OutlineInputBorder(
          borderSide: BorderSide(
            style: BorderStyle.solid,
          ),
        ),
      ),
      validator: (value) {
        if (value == null || value.isEmpty) {
          return 'Please select Product Code';
        }
        return null;
      },
      onFind: (text) async {
        var response = await Dio()
            .get('&quot;http://5d85ccfb1e61af001471bf60.mockapi.io/user');
        var models = ProductCodeModel.fromJsonList(response.data);
        return models;
      },
  ),
  </code></pre>
  <p>User Model :</p>
  <pre><code>class ProductCodeModel {
    final String id;
    final DateTime createdAt;
    final String name;
    final String avatar;
  
    ProductCodeModel({
      required this.id,
      required this.createdAt,
      required this.name,
      required this.avatar,
    });
  
    factory ProductCodeModel.fromJson(Map&lt;String, dynamic&gt; json) {
      return ProductCodeModel(
        id: json[&quot;id&quot;],
        createdAt: json[&quot;createdAt&quot;] = DateTime.parse(json[&quot;createdAt&quot;]),
        name: json[&quot;name&quot;],
        avatar: json[&quot;avatar&quot;],
      );
    }
  
    static List&lt;ProductCodeModel&gt; fromJsonList(List list) {
      return list.map((item) =&gt; ProductCodeModel.fromJson(item)).toList();
    }
  
    ///this method will prevent the override of toString
    String userAsString() {
      return '#$id $name';
    }
  
    ///this method will prevent the override of toString
    bool userFilterByCreationDate(String filter) {
      return createdAt.toString().contains(filter);
    }
  
    ///custom comparing function to check if two users are equal
    bool isEqual(ProductCodeModel model) {
      return id == model.id;
    }
  
    @override
    String toString() =&gt; name;
  }
  </code></pre>