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

feat: add option to enable or disable asset flag preload #237

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/src/phone_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class PhoneFormField extends FormField<PhoneNumber> {
/// The style of the country selector button
final CountryButtonStyle countryButtonStyle;

/// Whether the flag assets should be preloaded. It improves performance
/// by downloading them upfront (default). If set to false the assets will be
/// lazy loaded.
final bool isFlagPreloadEnabled;

// textfield inputs
final InputDecoration decoration;
final TextInputType keyboardType;
Expand Down Expand Up @@ -168,6 +173,7 @@ class PhoneFormField extends FormField<PhoneNumber> {
this.scrollController,
this.autofillHints,
this.enableIMEPersonalizedLearning = true,
this.isFlagPreloadEnabled = true,
}) : assert(
initialValue == null || controller == null,
'One of initialValue or controller can be specified at a time',
Expand Down
2 changes: 1 addition & 1 deletion lib/src/phone_form_field_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PhoneFormFieldState extends FormFieldState<PhoneNumber> {
);
controller.addListener(_onControllerValueChanged);
focusNode = widget.focusNode ?? FocusNode();
CountrySelector.preloadFlags();
if (widget.isFlagPreloadEnabled) CountrySelector.preloadFlags();
}

@override
Expand Down
Loading