Let's imagine you define a stream here:
Stream<MyUser> user = getStream();
void main() => runApp(MyApp());
Now it can be used to trigger StatefulWidget changes or with StreamBuilder anywhere in the widget tree.
class UserProfileState extends State<UserProfile> {
MyUser _user;
@override
initState() {
super.initState();
user.listen((user) => setState(() => _user = user ))
}
}
Are there any technical problems with a global stream/observable like this in Flutter? I've not been able to find examples of this pattern outside of inherited widgets or redux (which are far more complex).