I know there are ValueNotifier
, ChangeNotifier
and of course Stream
, but I can't find any class that can provide the new value directly to the listeners. I could of course create my own, but I'm wondering if there is such a class "built in" to Flutter?
Example (DirectValueNotifier
is what I'm looking for):
class MyClass extends DirectValueNotifier<String>{
void doSomething(){
String s = DateTime.now().toIso8601String();
notifyListeners(s);
}
}
MyClass myObj = MyClass();
myObj.addListener((s){
print('The time is $s');
});