Skip to content

Instantly share code, notes, and snippets.

@nmaruy27
Created December 13, 2020 08:48
Show Gist options
  • Save nmaruy27/b6472712c19f6ed209b59e887700847d to your computer and use it in GitHub Desktop.
Save nmaruy27/b6472712c19f6ed209b59e887700847d to your computer and use it in GitHub Desktop.
Sample code for useFocusNode for flutter hooks
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