streamBuilder(
stream: streamNumbers(),
builder: (context, snapshot) {
return Column(
children: [
Text("Stream Builder"),
Text("ConState : ${snapshot.connectionState}"),
Text("Data : ${snapshot.data}"),
Text("Error : ${snapshot.error}"),
FilledButton.tonal(
onPressed: () {
setState(() {});
},
child: Text("RESET"))
],
);
},
),
Stream<int> streamNumbers() async* {
for (int i = 0; i < 10; i++) {
await Future.delayed(Duration(seconds: 1));
yield i;
}
}
Dart
복사



