I am trying to get a list of groups with this function:
I am using GetX, RxDartand Streams.
Rx<Stream<List<FrediUserGroup>>> groupsStream = Rx<Stream<List<FrediUserGroup>>>(Stream.value([]));
List<FrediUserGroup> get groupList {
List<FrediUserGroup> groups = [];
groupsStream.value.listen((event) {
groups = event;
//print(groups) => [...,...,...,] prints list of complete groups
});
//always returns [];
return groups;
}
How can I wait for the listening to finish before returning the value?
OR How can I correctly return the listener function and return event inside of it (gives me an error: A value of type 'StreamSubscription<List<FrediUserGroup>>' can't be returned from the function 'groupList' because it has a return type of 'List<FrediUserGroup>'.