I tried getting input(string) from the user using textfield, adding the input in stream, and printing the string on a different screen, but instead of the string stream builder is printing null, I understood, it's because stream doesn't have any data. But I added data in stream once the user types out something in textfield and hit save.How do I love this
Stream
StreamController NameStream = StreamController.broadcast();
Adding data to stream
textField()
textbuttion(
onPressed: () {
addNStream() {
NameStream.sink.add(TextController);
}
setState(() {
addNStream();
});
)
Printing data in different screen
Scaffold(
body: Container(
child: StreamBuilder(
stream: NameStream.stream,
builder: (context, snapshot) {
return Center(
child: Text(
snapshot.data.toString(),
style: const TextStyle(fontSize: 40),
),
);
},
)
),
)