在Flutter中,当流的值更改时如何调用Navigator.push?我已经尝试了下面的代码,但出现错误。
StreamBuilder(
stream: bloc.streamValue,
builder: (BuildContext context, AsyncSnapshot<int> snapshot) {
if (snapshot.hasData && snapshot.data == 1) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SomeNewScreen()),
);
}
return Text("");
});
Run Code Online (Sandbox Code Playgroud)