title: How to rebuild children (& replay animations) after change in parent state
body: <p>My parent widget holds an <code>isLiked</code> <code>bool</code> field.</p>
  
  <p>When the child widgets are initially built, they play their animation. Note the following snippet:</p>
  
  <pre><code>@override
  void initState() {
      ...
      _animationController.forward();
  }
  </code></pre>
  
  <p>I am accessing the parent's state using an <code>InheritedWidget</code>. I tried adding <code>_animationController.reset()</code> to <code>initState()</code>, but this didn't work either.</p>
  
  <p>I think this child component is not being rebuilt when the parent state updates. I am using the following (reusable) code to pass state down the widget tree, as described in this <a href="https://medium.com/@maksimrv/reactive-app-state-in-flutter-73f829bcf6a7" rel="nofollow noreferrer">flutter reactive state article.</a></p>
  
  <pre><code>import 'package:flutter/widgets.dart';
  
  class Provider extends StatefulWidget {
    const Provider({this.data, this.child});
  
    static of(BuildContext context) {
      _InheritedProvider p =
          context.inheritFromWidgetOfExactType(_InheritedProvider);
      return p.data;
    }
  
    final data;
    final child;
  
    @override
    State&lt;StatefulWidget&gt; createState() =&gt; new _ProviderState();
  }
  
  class _ProviderState extends State&lt;Provider&gt; {
    @override
    initState() {
      super.initState();
      widget.data.addListener(didValueChange);
    }
  
    didValueChange() =&gt; setState(() {});
  
    @override
    Widget build(BuildContext context) {
      return new _InheritedProvider(
        data: widget.data,
        child: widget.child,
      );
    }
  
    @override
    dispose() {
      widget.data.removeListener(didValueChange);
      super.dispose();
    }
  }
  
  class _InheritedProvider extends InheritedWidget {
    _InheritedProvider({this.data, this.child})
        : _dataValue = data.value,
          super(child: child);
    final data;
    final child;
    final _dataValue;
  
    @override
    bool updateShouldNotify(_InheritedProvider oldWidget) {
      return _dataValue != oldWidget._dataValue;
    }
  }
  </code></pre>