Skip to content

Instantly share code, notes, and snippets.

@nmaruy27
Last active June 20, 2022 15:23
Show Gist options
  • Save nmaruy27/35e555657ad533aaffc0b14894155d96 to your computer and use it in GitHub Desktop.
Save nmaruy27/35e555657ad533aaffc0b14894155d96 to your computer and use it in GitHub Desktop.
useMemorizedを使ったGlobalKeyの生成
class HogeWidget extends HookConsumerWidget {
// 略
@override
Widget build(BuildContext context, WidgetRef ref {
// 略
final formKey = useMemorized(() => GlobalKey<FormBuilderState>());
// 略
return FormBuilder(
// 略
key: formKey
// 略
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment