title: Flutter animation doesn't work with data from Provider
body: <p>I've made a gradient progress indicator which worked fine until I wanted to add an animation. My application uses provider for storing everything in a ChangeNotifier class. I tried to add a listener to animate the change. When the data changes, I get:</p>
  
  <pre><code>════════ Exception caught by foundation library ════════════════════════════════════════════════════
  The following NoSuchMethodError was thrown while dispatching notifications for Tasks:
  The getter 'owner' was called on null.
  Receiver: null
  Tried calling: owner
  
  When the exception was thrown, this was the stack: 
  #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
  #1      Provider.of (package:provider/src/provider.dart:213:15)
  #2      _GradientProgressIndicatorState.didChangeDependencies.&lt;anonymous closure&gt; (package:todo/components/gradient_progress_indicator.dart:50:29)
  #3      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:206:21)
  #4      Category.createTask (package:todo/models/category.dart:35:8)
  ...
  The Tasks sending notification was: Instance of 'Tasks'
  ════════════════════════════════════════════════════════════════════════════════════════════════════
  
  </code></pre>
  
  <p>Here is my source code:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:provider/provider.dart';
  
  import '../models/tasks.dart';
  
  class GradientProgressIndicator extends StatefulWidget {
    final Color inactiveColor;
    final Gradient gradient;
  
    GradientProgressIndicator({this.inactiveColor, this.gradient});
  
    @override
    _GradientProgressIndicatorState createState() =&gt;
        _GradientProgressIndicatorState();
  }
  
  class _GradientProgressIndicatorState extends State&lt;GradientProgressIndicator&gt;
      with SingleTickerProviderStateMixin {
    double oldValue = 0;
    AnimationController controller;
    Animation animation;
  
    @override
    void initState() {
      super.initState();
      controller = AnimationController(
        vsync: this,
        duration: Duration(milliseconds: 500),
      );
      animation = Tween(
              begin: oldValue,
              end: Provider.of&lt;Tasks&gt;(context, listen: false)
                  .currentCategory
                  .taskPercentage)
          .animate(controller);
      oldValue = Provider.of&lt;Tasks&gt;(context, listen: false)
          .currentCategory
          .taskPercentage;
      controller.forward();
      controller.addListener(() {
        setState(() {});
      });
    }
  
    @override
    void didChangeDependencies() {
      Provider.of&lt;Tasks&gt;(context).addListener(() {
        animation = Tween(
                begin: oldValue,
                end: Provider.of&lt;Tasks&gt;(context, listen: false) //this is the line which the error mention
                    .currentCategory
                    .taskPercentage)
            .animate(controller);
        oldValue = Provider.of&lt;Tasks&gt;(context, listen: false)
            .currentCategory
            .taskPercentage;
        controller.forward();
      });
      super.didChangeDependencies();
    }
  
    @override
    void dispose() {
      controller.dispose();
      super.dispose();
    }
  
    @override
    Widget build(BuildContext context) {
      return Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.all(
            Radius.circular(5),
          ),
          color: widget.inactiveColor,
        ),
        height: 3,
        width: double.infinity,
        child: FractionallySizedBox(
          widthFactor: animation.value,
          alignment: Alignment.centerLeft,
          child: Container(
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(
                Radius.circular(5),
              ),
              gradient: widget.gradient,
            ),
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>(The <code>Provider.of&lt;Tasks&gt;(context, listen: false).currentCategory.taskPercentage</code> gives back a double between 0 and 1)<br>
  And that's what I get from flutter doctor:</p>
  
  <pre><code>[✓] Flutter (Channel master, v1.13.7-pre.12, on Linux, locale en_GB.UTF-8)
  
  [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
  [✓] Android Studio (version 3.5)
  [✓] Connected device (1 available)
  
  • No issues found!
  </code></pre>
  
  <p>Any ideas what is the source of the problem?</p>