Skip to content

Instantly share code, notes, and snippets.

@JulianBissekkou
Last active July 18, 2018 15:08
Show Gist options
  • Save JulianBissekkou/4f9dc2f5d381e8357ea317a2f593ce87 to your computer and use it in GitHub Desktop.
Save JulianBissekkou/4f9dc2f5d381e8357ea317a2f593ce87 to your computer and use it in GitHub Desktop.
// using "startWith" to ensure that the combined stream emitts even though
// on of two streams did not emmited any value yet
var combinedStream = Observable.combineLatest2(
title.startWith(""),
subtitle.startWith(""),
(title, subtitle) => Pair<String, String>(title, subtitle));
new StreamBuilder<Pair<String, String>>(
stream: combinedStream,
builder: (_, snapshot) {
if (snapshot.data == null) return Container();
var pair = snapshot.data;
return FancyTitleBar(title: pair.first, subtitle: pair.second);
},
);
// not sure if there is already an implementation of Pair, there you go:
class Pair<F, S> {
F first;
S second;
Pair(this.first, this.second);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment