title: A class was used after being disposed. Once you have called dispose() on a class, it can no longer be used
body: <p>The error says &quot;A MyData was used after being disposed.
  Once you have called dispose() on a MyData, it can no longer be used.&quot;. I am not being able to find where is dispose method called.
  Any help will be highly appreciated.</p>
  <p>main.dart</p>
  <pre><code>void main() {
    FlutterError.onError = (FlutterErrorDetails details) {
      FlutterError.dumpErrorToConsole(details);
      if (kReleaseMode) exit(1);
    };
    runApp(MyApp());
  }
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      SystemChrome.setPreferredOrientations([
        DeviceOrientation.portraitUp,
        DeviceOrientation.portraitDown,
      ]);
      return MultiProvider(
        providers: [
          ChangeNotifierProvider(
            create: (context) =&gt; Auth(),
          ),
  //////--------------------
          ChangeNotifierProxyProvider&lt;Auth, MyData&gt;(
            create: (_) =&gt; MyData('', 0),
            update: (ctx, auth, _) =&gt; MyData(
              auth.token,
              auth.user,
            ),
          ),
  //////--------------------
          &lt;other ChangeNotifierProvider s &amp; ChangeNotifierProxyProvider s&gt;
        ],
        child: Consumer&lt;Auth&gt;(
          builder: (ctx, auth, _) =&gt; MaterialApp(
            title: 'Flutter Demo',
            theme: ThemeData( all theme data ),
            home: auth.isAuth
                ? Home()
                : FutureBuilder(
                    future: auth.autoLogin(),
                    builder: (ctx, authResult) =&gt;
                        authResult.connectionState == ConnectionState.waiting
                            ? Splash()
                            : Login()),
            routes: { &lt;all the routes&gt; },
          ),
        ),
      );
    }
  }
  
  </code></pre>
  <p>home.dart</p>
  <pre><code>void didChangeDependencies() {
      if (_spinner == true) {
        Provider.of&lt;MyData&gt;(context, listen: false)
            .refreshData()
            .then((value) {
          if (value == true) {
            _chose =
                Provider.of&lt;MyData&gt;(context, listen: false).data.chose;
          } else {
            setState(() {
              _spinner = false;
            });
            return showDialog(
              context: context,
              builder: (ctx) =&gt; AlertBox(),
            );
          }
        }).catchError((error) {
          setState(() {
            _spinner = false;
          });
          return showDialog(
            context: context,
            builder: (ctx) =&gt; AlertBox(),
          );
        });
  </code></pre>
  <p>myData.dart</p>
  <pre><code>Future&lt;bool&gt; refreshData() async {
      final String _url = 'url here';
      return await http
          .get(_url, headers: {'authorization': '$_auth'}).then((value) async {
     
        if (value.statusCode == 401) {
          Auth().logout();
        }
  
        if (value.statusCode == 200) {
          final _extractedData = jsonDecode(value.body) as Map&lt;String, dynamic&gt;;
          _data = MyData(data);
          notifyListeners();
          return true;
        } else {
          return false;
        }
      }).catchError((error) {
        throw error;
      });
    }
  </code></pre>
  <p>error message (when error is not handled)</p>
  <pre><code>[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: A MyData was used after being disposed.
  Once you have called dispose() on a MyData, it can no longer be used.
  #0      ChangeNotifier._debugAssertNotDisposed.&lt;anonymous closure&gt; (package:flutter/src/foundation/change_notifier.dart:117:9)
  #1      ChangeNotifier._debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:123:6)
  #2      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:217:12)
  #3      MyData.refreshData (package:flutter_app_like4like/providers/myData.dart:210:7)
  &lt;asynchronous suspension&gt;
  #4      _HomeState.didChangeDependencies (package:flutter_app_like4like/screens/home.dart:43:12)
  #5      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4786:12)
  #6      ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
  #7      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
  #8      Element.updateChild&lt;…&gt;
  </code></pre>
  <p><strong>I am not being able to locate dispose().</strong>
  <strong>Any help will be useful</strong></p>