Created
May 1, 2019 18:58
-
-
Save fabiomsr/3e347fe6551bf24af864ff7734396979 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CounterListenableProvider extends InheritedWidget { | |
final ValueListenable<int> counter; | |
CounterListenableProvider({Key key, @required this.counter, Widget child}) | |
: super(key: key, child: child); | |
@override | |
bool updateShouldNotify(InheritedWidget oldWidget) { | |
return true; | |
} | |
static ValueListenable<int> of(BuildContext context) { | |
return (context.inheritFromWidgetOfExactType(CounterListenableProvider) | |
as CounterListenableProvider) | |
.counter; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment