title: Flutter ViewModel old data is repopulating (using Provider)
body: <p>I'm using multiProvider to manage state in flutter. The main problem that i'm facing is;
  Unable to clear the data inside my viewModel after closing a page. When i open the page again, old data is populating from viewModel.</p>
  <p>Because of this issue i've created a 'reset' method in my viewModel &amp; calling this 'reset' method before open the page.</p>
  <p>Is there any way to remove old values from viewModel :- Please suggest</p>
  <p>My code:</p>
  <p><strong>Main Page</strong>
  Adding providers under multi provider</p>
  <pre><code>class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MultiProvider(
          providers: [
            ChangeNotifierProvider.value(value: ViewModel1()),
            ChangeNotifierProvider.value(value: ViewModel2()),
          ],
          child: MaterialApp(
            title: 'Flutter Demo',
            theme: ThemeData(
            ),
            //Set Home Page after splash
            home: HomePage(),
          )
      );
    }
  }
  </code></pre>
  <p><strong>This is my Homepage</strong>  Navigate to FirstPage &amp; reset ViewModel1 data</p>
  <pre><code> HomePage()
     {
     :
     :
     :
     onPressed(){
       Navigator.push(
          context, MaterialPageRoute(builder: (context) =&gt; FirstPage()));
       Provider.of&lt;ViewModel1&gt;(context, listen: false).reset();
                }
    }
  </code></pre>
  <p>This is My Page:</p>
  <pre><code>class FirstPage extends StatefulWidget {
    @override
    _FirstPageState createState() =&gt; _FirstPageState();
  }
  
  class _FirstPageState extends State&lt;FirstPage&gt; {
    @override
    Widget build(BuildContext context) {
      final ViewModel1 _viewModel1 =
      Provider.of&lt;ViewModel1&gt;(context, listen: true);
  
      TextFormField(
        controller: _fNameController,
        onChanged: _viewModel1.setFname,
      );
    }
  }
  </code></pre>
  <p>This is my ViewModel:</p>
  <pre><code>class ViewModel1 with ChangeNotifier {
    String _fName = '';
  
    String get fName =&gt; _fName;
  
    setFname(String fName) {
      _fName = fName;
      notifyListeners();
      setFnameValidation(fName
          .trim()
          .isNotEmpty ? true : false);
    }
  
    //TODO Reset all values
    void reset() {
      _fName = '';
      notifyListeners();
    }
  }
  
  
     
  </code></pre>