Skip to content

Instantly share code, notes, and snippets.

@nkenna
Created October 29, 2019 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkenna/5a0d56941c2d7f0658f8aa09a62fc0f9 to your computer and use it in GitHub Desktop.
Save nkenna/5a0d56941c2d7f0658f8aa09a62fc0f9 to your computer and use it in GitHub Desktop.
@override
void initState() {
// TODO: implement initState
super.initState();
Timer.periodic(Duration(seconds: 100), (timer) { //ask the server for humuidity value every 100 seconds
print('sending periodic message: hh');
widget.channel.sink.add('humidity'); // send message to server
setState(() {
humidity = humidd; // change the value of temperature with the recent result from server.
});
});
Timer.periodic(Duration(seconds: 115), (timer) { //ask the server for temperature value every 115 seconds
print('sending periodic message: temp');
widget.channel.sink.add('temperature'); // send message to server
setState(() {
temperature = tempp;
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment