Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional function to execute on done form #55

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/credit_card_form.dart
Expand Up @@ -40,6 +40,7 @@ class CreditCardForm extends StatefulWidget {
this.isHolderNameVisible = true,
this.isCardNumberVisible = true,
this.isExpiryDateVisible = true,
this.onFormComplete,
}) : super(key: key);

final String cardNumber;
Expand All @@ -59,6 +60,7 @@ class CreditCardForm extends StatefulWidget {
final bool isCardNumberVisible;
final bool isExpiryDateVisible;
final GlobalKey<FormState> formKey;
final Function? onFormComplete;

final InputDecoration cardNumberDecoration;
final InputDecoration cardHolderDecoration;
Expand Down Expand Up @@ -266,6 +268,9 @@ class _CreditCardFormState extends State<CreditCardForm> {
else {
FocusScope.of(context).unfocus();
onCreditCardModelChange(creditCardModel);
if (widget.onFormComplete != null) {
widget.onFormComplete!();
}
}
},
style: TextStyle(
Expand Down Expand Up @@ -312,6 +317,9 @@ class _CreditCardFormState extends State<CreditCardForm> {
onEditingComplete: () {
FocusScope.of(context).unfocus();
onCreditCardModelChange(creditCardModel);
if (widget.onFormComplete != null) {
widget.onFormComplete!();
}
},
),
),
Expand Down