smart_field_kit 0.0.2
smart_field_kit: ^0.0.2 copied to clipboard
Flutter form fields on native Material behavior: validation, formatting, masking, phone, OTP, amount, card, and date inputs in one API.
0.0.2 #
Changed #
This release contains breaking changes. While the version is 0.0.x, ^0.0.1 does not select it automatically; update the constraint to ^0.0.2 when you are ready to migrate.
- Breaking: use
package:material_ui(Flutter's standalone Material package) instead of the in-frameworkpackage:flutter/material.dart, which Flutter 3.50 deprecates. Public parameters that take Material types now take thematerial_uitypes. Migrate your app withdart fix --apply --code=migrate_design_widgets. - Breaking: require Flutter 3.47.0 or later and Dart 3.13.0 or later (0.0.1 required Flutter 3.44.0).
- Show the phone country picker in a sheet built by this package, so it follows your
material_uitheme. Country data still comes fromcountry_picker. Search hint, flags, favorites, allowed countries and selection callbacks behave as before. - Load the native contact-picker plugin only where
dart:ioexists, so the package compiles for web and WebAssembly. The contact button is still shown only on Android and iOS.
Added #
- Declare Windows and Linux as supported platforms. The package analysis and tests run on hosted Windows and Linux runners, and the example is built for both.
- Build the example for WebAssembly, Linux, Windows and macOS in CI, and run the package on the latest stable Flutter.
0.0.1 #
Added #
- Confirm-password fields are invalid when empty while the original is filled, and revalidate on original edits only as
autovalidateModeallows.SmartValidators.matchesgainsrequireWhenOtherFilled. - Add
SmartCardBrandMatch.detection(identified,ambiguous,unknown),SmartCardBrand.securityCodeName, andSmartCardNumberAssessment.canBeLongerandisFinal. - Add
SmartAsyncValidation.revalidationKeyto drop results and re-check when the validation rule changes. - Add opt-in
normalizeDigitson number, amount, percentage, phone, OTP, card, date, time, and date-time fields, withSmartDigitNormalizationFormatterandSmartTextUtils.normalizeDigits, for Arabic-Indic, Persian, and fullwidth digits. - Add opt-in
acceptDotAsDecimalonSmartField.amountandSmartAmountFormatter. - Add
amLabelandpmLabelonSmartField.time,SmartField.dateTime, andSmartTimeFormat. - Add API documentation comments to the exported classes, constructors, and functions.
- Add the normal SmartField widget with native TextFormField behavior.
- Add opt-in required and grapheme-aware length validation with reusable validators.
- Add SmartField.email with practical default and opt-in legacy validation policies.
- Add SmartField.password with optional legacy policies and accessible visibility control.
- Add SmartField.number with exact optional value bounds and legacy validation.
- Add SmartField.amount with exact decimal formatting, raw callbacks, grouping, currency, and legacy validation.
- Add SmartField.name and SmartField.username with flexible Unicode defaults and five optional legacy text-validation presets.
- Add SmartField.otp with a native single-input box layout, autofill, exact validation, controlled errors, completion callbacks, responsive styling, and the optional legacy rule.
- Add SmartField.description and SmartField.text with native multiline layout, automatic height growth, shared line configuration, and the final two legacy text presets.
- Add independent phone, account, and amount masking utilities plus opt-in masked presentation for phone, number, and amount fields.
- Add SmartField.search with native search input behavior, accessible clear and loading states, and optional debounced search events.
- Add SmartField.percentage with a visual percent suffix, exact raw decimal strings, and opt-in sign, precision, and range rules.
- Add SmartField.url with raw-value preservation, complete http/https syntax validation, and opt-in scheme and bare-domain policies.
- Add optional asynchronous validation for every SmartField type with debounce, triggers, stale-result protection, loading and unavailable states, and an awaitable SmartFieldAsyncController.
- Add shared fallback design (12px outline, 1px/2px borders, 16x12 padding) that yields to the field decoration and the app theme.
- Add four validation modes with selectable built-in checks, password rule checks, and field matching for confirm password.
- Add word limits and a word counter for SmartField.description and SmartField.text.
- Add optional text-case, username, and whitespace formatters and the SmartTextUtils helpers.
- Add SmartField.amount decimalLength (false, 1, 2, 3), explicit rounding modes, and Indian grouping.
- Add SmartServerError for manual server messages on every field and optional state restoration.
- Add SmartField.creditCard with brand-aware grouping, Luhn and expiry validation, concealed security code, and no persistence of card data.
- Add SmartField.date (manual, calendar, dropdowns, wheel), SmartField.time, and SmartField.dateTime with typed values and timezone-free ISO serialization.
- Add generic pattern masks for SmartField.text with separate raw and display values.
- Add an optional password-strength indicator with developer-defined criteria.
- Add a long-press Paste menu to the OTP field.
- Add optional
initialValue,onFieldSubmitted,onEditingComplete,onTap,onTapOutside,style,textAlign,textDirection, andobscuringCharacterparameters to the text-based constructors. - Add optional text overrides:
wordCountBuilder,strengthTitle, the five password-rule messages,allowedCharactersErrorText,contactPickerMessageBuilder,showCvvLabel, andhideCvvLabel. - Export
SmartNumberInputFormatter.
Changed #
- Email: with the standard policy, asynchronous validation now receives the address without surrounding spaces, the same value
onSavedreceives. - Declare Android, iOS, macOS, and web as supported platforms in
pubspec.yaml. - Refactor SmartField internals into a shared core with one owned controller and focus node path and a shared design resolver.
- Make SmartPhonePolicy.auto validate international numbers with the parser-inferred country when no country is selected.
- Refactor SmartField internals: one shared private base class with default values, constructors that build their configuration directly, shared listener, input-handle, validation-mode, raw-value, and suffix helpers, and smaller field state (phone, amount display, search debounce, and password strength moved to focused helpers). No public API changes.
- Credit card: UnionPay is now exempt from the Luhn checksum by default because its numbers are not required to pass it; every other brand always requires it. The checksum, the brand lengths and the security-code lengths cannot be disabled or overridden;
acceptedBrandsonly narrows the brands. Strength indicator is skipped while a mask is shown, as before the feature refactor. - Group the card number, expiry, and security-code fields for platform autofill.
- Lower the Dart SDK constraint to
^3.12.0after verifying analysis, tests, and the example build on Flutter 3.44.0. - Asynchronous validation no longer compares validator functions: a parent rebuild keeps the pending check and the completed result, and
validateAsync(force: true)applies a changed rule with one new request, also while a check is pending. - Search: a parent rebuild no longer cancels a pending debounced
onSearch; the callback from the latest build is called. - Call date
onRawChangedwith an empty string when a valid value is cleared or becomes invalid. - Return the same normalised text from amount
onRawSavedwhether or not the field has focus. - Apply
maxLengthto whitespace-only text and count grapheme clusters inSmartPasswordCriterion.minLength. - Reject card numbers made only of zeros.
- OTP: remove spaces and hyphens from pasted text, drop extra digits, let a typed digit replace a filled box, and report each distinct completed code.
- Phone: ignore non-breaking spaces, dots, and invisible direction marks during validation and parsing.
- Email: ignore surrounding spaces during validation and pass the trimmed address to
onSaved. - Masked phone, number, and amount fields are reported to assistive technology as obscured fields with a separate masked value, so a screen reader no longer reads the raw value.
maskAmountmasks every digit whenvisibleSuffixDigitscovers the whole amount, accepts a minus sign before the currency text, accepts Indian grouping, and rejects digits from other scripts. A masked amount field keeps its currency symbol.- Amount: after a rebuild with different currency, grouping, separator, or decimal settings, valid text is shown in the new format.
- Amount:
acceptDotAsDecimalleaves a dot inside the currency symbol alone. - OTP: remove any whitespace and invisible formatting characters from pasted codes, and trim the text when
lengthbecomes shorter. - Phone: a contact number from another allowed country, including one that shares the selected country's dialing code, is accepted and selects that country.
- URL: reject invisible and direction-changing characters.
- Password rules: spaces, control characters, and invisible characters no longer count as special characters. Legacy policies are unchanged.
- Date:
pastOnlyandfutureOnlypicker limits use calendar days;minDateTimeis compared to the minute; a reversedfirstYear/lastYearpair is asserted. - Card and OTP fields turn off keyboard personalized learning.
- Asynchronous validation: removing
asyncValidationclears its error at once, and a finished or dropped check leaves no timeout timer running. minValueandmaxValuecompare very long values in linear time.- Credit card: focus moves to the expiry only when the brand is identified, the number is valid, and the brand has no longer length. A valid 16-digit or 18-digit Visa number no longer moves focus; Mastercard and American Express still do. Discover, JCB, Maestro, Mir, Diners Club, Verve, and UnionPay move at 19 digits.
- Credit card: a checksum that fails at a length shorter than the brand's longest is
incompletewithissue: failsChecksuminstead ofinvalid, and the field shows guidance instead of an error until the form is validated. This affects 16-digit Visa, Discover, JCB, UnionPay, Maestro, Mir, Diners Club, Verve, and unknown-brand numbers. - Credit card: with
acceptedBrands, the brand error appears as soon as no accepted brand can match the typed digits. - Credit card: the security-code hint shows the identified brand's code name unless
cvvHintis set. - Credit card: brand detection, number assessment, the checksum, and the formatter no longer create regular expressions or intermediate maps per call. Detection results are unchanged.
SmartCardUtils.formatandmaskedNumbergroup very long digit strings in linear time.- Asynchronous validation: a debounce that is waiting when
triggerchanges away fromonChangedno longer starts a check. SmartDecimalUtils.roundno longer includes the rejected text in its exception.- The wheel picker header and the OTP boxes no longer overflow on narrow screens with large text.
- Credit card: label the security-code toggle
Show security code/Hide security code, and apply decoration labels and icons to the number field only.
Fixed #
- Fix masked phone, number, and amount text overlapping icons or leaving the field after a rebuild; it is now placed from the field's live layout, scaled to no less than 60%, and keeps its last digits visible.
- Fix masked fields throwing when the decoration has a
prefixwidget, and apply the fieldstyleand disabled colour to masked text. - Fix
FormState.reset()followed bysave()returning the previously typed value for date, time, date-time, masked, and other fields that own their controller. - Fix a date, time, or date-time field with an external controller saving an empty value when
save()is called immediately afterreset(). - Fix the OTP field keeping the old value for
save()andvalidate()after its controller is replaced. - Fix dropdown dates reloading
initialDatewhen an external controller is cleared, and asynchronous validation using an outdated date format. - Fix an error raised when an asynchronous-validation status listener rebuilds a parent while the field is disabled or its controller is replaced.
- Credit card: do not move focus to the expiry before a checksum-exempt number, such as a 19-digit UnionPay number, reaches its longest length, and do not ask the platform to save the card when the field is removed.
- OTP: a full code inserted into a partly filled field replaces the existing digits instead of producing a truncated code.
- Fix masked phone, number, and amount text being cut off on narrow screens with large text; it is now drawn smaller to fit.
- Remove a dropped asynchronous error within the same frame instead of one frame later.
- Remove a displayed asynchronous validation error when its result is dropped because the text controller was replaced or the field was disabled; the field then shows the validation state of its current value.
- Expose each password-strength checklist rule to screen readers with a checked or not-checked state.
- Fix layout overflow in the phone field's country prefix at large text sizes and in date dropdowns on very narrow widths.
- Wheel date picker: roll back to the nearest allowed date and disable confirmation when the wheels stop outside
minDate,maxDate, orrestriction. - Keep the selected phone country, a revealed password, pending searches, and other per-feature state when an unrelated feature such as
mask,serverError, orasyncValidationis added or removed. - Stop amount display formatting on load, focus, and focus loss from calling
Form.onChangedor triggeringAutovalidateMode.onUserInteraction. - Remove text that a number, amount, username, mask, card, or OTP input rule rejects when a composing keyboard commits it, by returning to the text held before the composition.
- Fix the contact picker storing an inferred country when no country picker is shown, guard it against overlapping opens, keep disabled OTP fields unfocusable, and clear server errors on OTP edits.
- Fix date dropdown mode failing a framework assertion when the stored date is outside the selectable years; the date is kept, shown, and reported through validation.
- Fix date dropdown
FormState.reset()followed bysave()returning a date that was no longer visible. - Discard date, time, date-time, wheel, and country picker results when the field was disabled, made read-only, given another controller, or removed while the picker was open.
- Stop amount and date fields from writing to a developer-owned controller during build, which could throw
setState() or markNeedsBuild() called during build. - Run automatic asynchronous validation after a selection in calendar, wheel, and clock picker modes.
- Keep OTP text, selection, and focus when asynchronous validation is added to or removed from a field without an external controller.
- Recompute the card security-code length error when the card-number controller or allowed lengths change.
- Return an invalid result instead of throwing for URLs with oversized numeric host components.
- Enforce
SmartField.username(allowedCharacters:)through validation as well as input formatting. - Fix right-to-left layouts reordering digits: OTP boxes, card numbers, phone numbers and dial codes, grouped and negative amounts, percentages, and 12-hour times now keep typed order.
- Expose a tap action to assistive technology on the password visibility toggle and the search clear button; announce the OTP label, country button, and date dropdown labels once; make date dropdowns 48 logical pixels high with a focused border.
- Keep a pending debounced search when only the caret moves.
- Clear an outdated server error when the phone clear button or contact picker changes the value.
- Fix forward Delete on an input-mask literal or card-number space removing the character before the caret.
- Fix caret placement for amounts whose currency symbol contains a decimal separator or a digit.
- Honour
showClearButtonin date dropdown mode, give the month more room in narrow layouts, and roughly halve dropdown rebuild cost.
Testing & Documentation #
- Add SmartField.phone with optional country selection, metadata validation, safe E.164 values, native contact selection, and legacy validation.
- Credit card: add a verified brand metadata table (Troy, Elo, Mir, Hiper, Hipercard, Naranja, Verve added), uncertainty-aware brand detection, instant local number status with neutral guidance, per-brand grouping, brand-aware security-code re-checks, Luhn options, and redacted diagnostics.
- Add a complete interactive Flutter example application demonstrating SmartField constructors, validation modes, formatting, masking, asynchronous validation, credit-card fields, date/time fields, and customization.
- Add responsive example layouts with light/dark theme switching, RTL layout, and adjustable text scaling.
- Add genuine Flutter example screenshots and animated GIF demonstration assets, with screenshot metadata configured for pub.dev.
- Add pub.dev package metadata, including homepage, repository, issue tracker, topics, and screenshot descriptions.
- Configure GitHub Actions CI for formatting, static analysis, package tests, coverage, example tests, web builds, and publication dry runs.
- Expand package documentation with installation instructions, quick-start examples, public API guidance, validation, formatting, masking, customization, and security limitations.
- Add a README quick-start regression test to verify that the documented signup example remains compatible with the public API.
- Add an example application README with setup instructions, feature overview, and screenshot-capture information.
- Add initial
.pubignorerules for internal development references, historical reports, generated files, and unnecessary example-platform assets. - Make the test suite pass on Chrome, add Chrome, Windows, macOS, and minimum-SDK jobs to CI, add real-engine integration tests, and add the missing macOS Podfile to the example.
