Created
December 10, 2021 08:15
-
-
Save Zfinix/d6121ed56bb4684705d5759627ae8d81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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