Reputation: 183
I have a stream from Bluetooth and I want to extract the data and send it to another widget but I am having a problem with the return of the widget. this is my code.
StreamBuilder<List<int>>(
stream: stream,
builder: (BuildContext context, AsyncSnapshot<List<int>> snapshot) {
if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
}
if (snapshot.connectionState == ConnectionState.active) {
// geting data from bluetooth
var currentValue = _dataParser(snapshot.data);
if (currentValue != "nan") {
return temperature = double.parse('${currentValue}');
}
}
});
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const [
Text('Temperature:'),
Text('20'), // I want temperature here
],
);
}
I want to pass temperature to be written instead of 20 in the Text widget.
what shall I put after return?
Upvotes: 0
Views: 54