I want to use multiple GetX controllers in my widget. The StreamBuilder of the async package offers the possibility to combine streams like in the code below. Is there any way to use this approach with the GetX? I would not like to nest the GetX as this leads to ugly code.
@override
Widget build(BuildContext context) {
return StreamBuilder<List<dynamic>>(
stream: CombineLatestStream.list(
[
_profileStore.getProfileStream(),
_journalStore.getJournalStream(),
],
),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(child: CircularProgressIndicator());
}
final Profile profile = snapshot.data![0];
final List<Dream> journal = snapshot.data![1];
...
}
);
}
My current widget with GetX looks like this.
@override
Widget build(BuildContext context) {
return GetX<ProfileStore>(
builder: (store) {
return Text('${store.profile.value.username}');
}
);
}