title: I want to create a custom DropdownButton in flutter which can be reusable with different List [Flutter]
body: <p>Here I have four Lists as in the code below and is it possible to call the list through parameter od any someother way for reusable purpose, example if I have four DropDown Button and each DropDown Button contains different Lists so how i can create a reusable code for implement this.</p>
  <p>Here is what i tried,</p>
  <pre><code>import 'package:flutter/material.dart';
  
  class CustomDropDown extends StatefulWidget {
    final String HintName;
    final List&lt;String&gt; MDPT;
  
    CustomDropDown({required this.HintName, required this.MDPT});
    @override
    _CustomDropDownState createState() =&gt; _CustomDropDownState();
  }
  
  class _CustomDropDownState extends State&lt;CustomDropDown&gt; {
    String? dropdownvalue;
    var MDPackageType = [
      'Package Type 1',
      'Package Type 2',
      'Package Type 3',
      'Package Type 4',
    ];
    var MDPackageName = [
      'Package Name 1',
      'Package Name 2',
      'Package Name 3',
      'Package Name 4',
    ];
  
    var PTPackageType = [
      'Package Type 1',
      'Package Type 2',
      'Package Type 3',
      'Package Type 4',
    ];
    var PTPackageName = [
      'Package Type 1',
      'Package Type 2',
      'Package Type 3',
      'Package Type 4',
    ];
  
    @override
    Widget build(BuildContext context) {
      return FormField&lt;String&gt;(
        builder: (FormFieldState&lt;String&gt; state) {
          return InputDecorator(
            decoration: InputDecoration(
              // labelStyle: textStyle,
  
              // errorStyle: TextStyle(color: Colors.redAccent, fontSize: 16.0),
              hintText: 'Package Type',
              border: OutlineInputBorder(
                borderRadius: BorderRadius.circular(5.0),
              ),
            ),
            isEmpty: dropdownvalue == '',
            child: DropdownButtonHideUnderline(
              child: DropdownButton&lt;String&gt;(
                hint: Text(
                  widget.HintName,
                  style: TextStyle(color: Colors.blue),
                ),
                value: dropdownvalue,
                isDense: true,
                onChanged: (String? newValue) {
                  setState(() {
                    dropdownvalue = newValue;
                    state.didChange(newValue);
                  });
                },
  
                
                items: MDPT.map((String value) {
                  return DropdownMenuItem&lt;String&gt;(
                    value: value,
                    child: Text(
                      value,
                      style: TextStyle(color: Colors.blue),
                    ),
                  );
                }).toList(),
              ),
            ),
          );
        },
      );
    }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/V1b4N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V1b4N.png" alt="My expected Output" /></a></p>