feat: textField 新增 focusNode 設置
新增 focusNode 用以控制游標目標位置
This commit is contained in:
parent
7c33bd99d9
commit
7e6b0df97f
|
|
@ -18,6 +18,7 @@ class RegisterPage extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _RegisterPageState extends State<RegisterPage> {
|
||||
late FocusNode _nameFocusNode, _emailFocusNode, _passwordFocusNode, _codeFocusNode;
|
||||
final TextEditingController _nameController = TextEditingController();
|
||||
final TextEditingController _emailController = TextEditingController();
|
||||
final TextEditingController _passwordController = TextEditingController();
|
||||
|
|
@ -33,6 +34,10 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
void initState() {
|
||||
super.initState();
|
||||
_fetchData();
|
||||
_nameFocusNode = FocusNode();
|
||||
_emailFocusNode = FocusNode();
|
||||
_passwordFocusNode = FocusNode();
|
||||
_codeFocusNode = FocusNode();
|
||||
}
|
||||
|
||||
void _fetchData() async {
|
||||
|
|
@ -124,7 +129,6 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
databaseName: 'care',
|
||||
);
|
||||
await conn.connect();
|
||||
|
||||
try {
|
||||
String name = _nameController.text;
|
||||
String email = _emailController.text;
|
||||
|
|
@ -172,8 +176,13 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
super.dispose();
|
||||
_timer?.cancel();
|
||||
|
||||
_nameFocusNode.dispose();
|
||||
_emailFocusNode.dispose();
|
||||
_passwordFocusNode.dispose();
|
||||
_codeFocusNode.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -207,6 +216,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
SizedBox(height: 20),
|
||||
TextField(
|
||||
controller: _nameController,
|
||||
focusNode: _nameFocusNode,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.person_outlined),
|
||||
|
|
@ -216,6 +226,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
SizedBox(height: 20),
|
||||
TextField(
|
||||
controller: _emailController,
|
||||
focusNode: _emailFocusNode,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.email_outlined),
|
||||
|
|
@ -226,6 +237,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
SizedBox(height: 20),
|
||||
TextField(
|
||||
controller: _passwordController,
|
||||
focusNode: _passwordFocusNode,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.lock_outlined),
|
||||
|
|
@ -251,6 +263,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
Expanded(
|
||||
child: TextField(
|
||||
controller: _codeController,
|
||||
focusNode: _codeFocusNode,
|
||||
decoration: InputDecoration(
|
||||
labelText: '驗證碼',
|
||||
hintText: '填寫驗證碼',
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user