Created
December 6, 2019 18:38
-
-
Save iampawan/efeff11154c6eba795ddf37730263968 to your computer and use it in GitHub Desktop.
Keyboard freeze issue.
This file contains 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
import 'package:flutter/material.dart'; | |
class AliceExample extends StatefulWidget { | |
@override | |
_AliceExampleState createState() => _AliceExampleState(); | |
} | |
class _AliceExampleState extends State<AliceExample> { | |
TextEditingController _textController; | |
FocusNode focusNode; | |
@override | |
void initState() { | |
super.initState(); | |
_textController = TextEditingController(); | |
focusNode = FocusNode(); | |
} | |
_onTextChanged() { | |
_textController.text = ""; | |
} | |
@override | |
Widget build(BuildContext context) { | |
print("Restarted"); | |
// var cursorPos = new TextSelection.fromPosition(new TextPosition(offset: 0)); | |
// _textController.selection = cursorPos; | |
_textController.addListener(_onTextChanged); | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Network Tool"), | |
), | |
body: SingleChildScrollView( | |
child: Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: <Widget>[ | |
TextField( | |
maxLength: 2, | |
controller: _textController, | |
onChanged: (String str) { | |
focusNode.unfocus(); | |
}, | |
focusNode: focusNode, | |
) | |
], | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment