Last active
July 18, 2018 15:08
-
-
Save JulianBissekkou/4f9dc2f5d381e8357ea317a2f593ce87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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