Skip to content

Instantly share code, notes, and snippets.

@Zfinix
Created December 10, 2021 08:15
Show Gist options
  • Select an option

  • Save Zfinix/d6121ed56bb4684705d5759627ae8d81 to your computer and use it in GitHub Desktop.

Select an option

Save Zfinix/d6121ed56bb4684705d5759627ae8d81 to your computer and use it in GitHub Desktop.
class WifiLCDPage extends StatefulWidget {
const WifiLCDPage(this.channel, {Key? key}) : super(key: key);
final Socket? channel;
@override
State<WifiLCDPage> createState() => _WifiLCDPageState();
}
class _WifiLCDPageState extends State<WifiLCDPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Arduino LCD'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 30),
child: TextField(
onSubmitted: sendMessage,
style: const TextStyle(
color: Colors.black,
fontSize: 14.0,
),
decoration: const InputDecoration(
labelText: 'Enter Input',
border: OutlineInputBorder(),
),
),
),
],
),
));
}
void sendMessage(String str) {
try {
widget.channel
?..write('clear')
..write(str);
} catch (e) {
debugPrint(e.toString());
}
}
@override
void dispose() {
widget.channel?.close();
super.dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment