Created
December 13, 2020 08:48
-
-
Save nmaruy27/b6472712c19f6ed209b59e887700847d to your computer and use it in GitHub Desktop.
Sample code for useFocusNode for flutter hooks
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'; | |
import 'package:flutter_hooks/flutter_hooks.dart'; | |
class CustomTextFormField extends HookWidget { | |
CustomTextFormField({Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final _focusNode = useFocusNode(); | |
final _controller = useTextEditingController(); | |
_focusNode.addListener(() { | |
debugPrint("Focus Change : " + _focusNode.hasFocus.toString()); | |
}); | |
return Container( | |
child: TextFormField( | |
maxLines: null, | |
minLines: 500, | |
focusNode: _focusNode, | |
controller: _controller, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment