Skip to content

Instantly share code, notes, and snippets.

@yaizudamashii
Last active April 9, 2021 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaizudamashii/cd9837c0f26a99a4337280b8405ee124 to your computer and use it in GitHub Desktop.
Save yaizudamashii/cd9837c0f26a99a4337280b8405ee124 to your computer and use it in GitHub Desktop.
// 他の関数など...
void _updateFormType(EmailPasswordSignInFormType formType) {
model.updateFormType(formType);
_emailController.clear();
_passwordController.clear();
}
Widget _buildContent() {
return FocusScope(
node: _node,
child: Form(
onChanged: () => model.updateWith(
email: _emailController.text, password: _passwordController.text),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
const SizedBox(height: 8.0),
_buildEmailField(),
if (model.formType != EmailPasswordSignInFormType.forgotPassword) ...<Widget>[
const SizedBox(height: 8.0),
_buildPasswordField(),
],
const SizedBox(height: 8.0),
FormSubmitButton(
key: const Key('primary-button'),
text: model.primaryButtonText,
initialLoading: model.isLoading,
onPressed: model.isLoading ? null : _submit,
),
const SizedBox(height: 8.0),
TextButton(
key: const Key('secondary-button'),
child: Text(model.secondaryButtonText),
onPressed: model.isLoading
? null
: () => _updateFormType(model.secondaryActionFormType),
),
if (model.formType == EmailPasswordSignInFormType.signIn)
TextButton(
key: const Key('tertiary-button'),
child: const Text(
EmailPasswordSignInStrings.forgotPasswordQuestion),
onPressed: model.isLoading
? null
: () => _updateFormType(
EmailPasswordSignInFormType.forgotPassword),
),
],
),
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment