title: How to use same Provider Package Class in same kind of two widgets which are used for different purpose
body: <p><a href="https://i.stack.imgur.com/6fZbP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6fZbP.png" alt="enter image description here" /></a></p>
  <p>I have used two DropDownWidget in my app.
  First drop down widget stores city value, second drop down stores area. To find area we need user's selected city's value.</p>
  <p>I have used same DropDownWidgetProvider state management in both DropDownWidget, but now i can't find any way to pass data from one object of DropDownWidgetProvider to another.</p>
  <p>Could anyone recomment what mistake i have done. It would be very helpful.</p>
  <p>Below is my Code:
  <strong>Implementation Code</strong></p>
  <pre><code>Consumer&lt;LoadCityAndAreaProvider&gt;(
  
                              builder: (context,loadCityAndAreaProvider,child){
                                String cityValue='';
                                return Row(
                                  children: [
                                    Expanded(
                                        child: ChangeNotifierProvider(
                                          create:(context)=&gt;DropDownWidgetProvider(),
                                          child: Consumer&lt;DropDownWidgetProvider&gt;(
                                            builder:(context,dropDownWidgetProvider,child){
                                              cityValue=dropDownWidgetProvider.selectedIndex;
                                              return  DropDownWidget(
                                                  heading: 'City',hintText: 'Choose City',namesList:loadCityAndAreaProvider.getCityNamesList
                                              );
                                            }
                                          ),
                                        )
                                    ),
                                    constants.kMediumBox,
                                    Expanded(
                                        child: ChangeNotifierProvider(
                                          create:(context)=&gt;DropDownWidgetProvider(),
                                          child: Consumer&lt;DropDownWidgetProvider&gt;(
                                              builder:(context,dropDownWidgetProvider,child){
                                                return  DropDownWidget(
                                                    heading: 'Area',hintText: 'Choose Area',namesList:loadCityAndAreaProvider.getAreaNamesList(cityValue)
                                                );
                                                }
  
                                        )
                                    ),
                                    ),
                                  ],
                                );
                              },
                            ),
  </code></pre>
  <p><strong>DropDownWidgetProvider</strong></p>
  <pre><code>
  class DropDownWidgetProvider with ChangeNotifier{
    String? _selectedIndex;
  
  
    String get selectedIndex{
      if (_selectedIndex==null){
        return '';
      }
      else {
        return _selectedIndex!;
      }
    }
    void updateSelectedIndex(String newSelectedIndex){
      _selectedIndex=newSelectedIndex;
      notifyListeners();
  }
  }
  </code></pre>
  <p><em><strong>Drop Down</strong></em></p>
  <pre><code>onChanged: (newValue) {
                      Provider.of&lt;DropDownWidgetProvider&gt;(context,listen:false).updateSelectedIndex(newValue!);
                      setState(() {
                        value = newValue;
                      });
                    },
  </code></pre>
  <blockquote>
  <p>Sorry For my poor english</p>
  </blockquote>