Skip to content

Instantly share code, notes, and snippets.

@nkenna
Created October 29, 2019 10:34
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/b782e1c7a0f6f1d4780658feba0dee10 to your computer and use it in GitHub Desktop.
Save nkenna/b782e1c7a0f6f1d4780658feba0dee10 to your computer and use it in GitHub Desktop.
new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text('Front Light'),
new Switch(
value: widget.toggleFL,
onChanged: (value){
setState(() {
widget.toggleFL = value; // toggle the button and its value
});
print(widget.toggleFL);
if(widget.toggleFL == true){
print(':Publishing our topic: frontlite1');
widget.channel.sink.add("frontlite1"); // send message to server to ON frontlite
}else{
print(':Publishing our topic: frontlite0');
widget.channel.sink.add("frontlite0"); // send message to OFF frontlite
}
}),
],
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment