Skip to content

Commit

Permalink
Merge pull request #21 from tappeddev/validate_on_new_input
Browse files Browse the repository at this point in the history
fix validating after input
  • Loading branch information
stefanschaller authored Jul 11, 2024
2 parents 6a911d4 + d4d4e2c commit a13c9eb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
4 changes: 0 additions & 4 deletions .fvm/fvm_config.json

This file was deleted.

24 changes: 6 additions & 18 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
- uses: kuhnroyal/flutter-fvm-config-action@v1
with:
path: '.fvm/fvm_config.json'
- uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
- name: Get all dependencies
run: flutter pub get
- name: analyze app
Expand All @@ -30,13 +26,9 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
- uses: kuhnroyal/flutter-fvm-config-action@v1
with:
path: '.fvm/fvm_config.json'
- uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
- name: Get all dependencies
run: flutter pub get
- name: Check formatting
Expand All @@ -47,13 +39,9 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
- uses: kuhnroyal/flutter-fvm-config-action@v1
with:
path: '.fvm/fvm_config.json'
- uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
- name: Get all dependencies
run: flutter pub get
- name: Check formatting
Expand Down
11 changes: 8 additions & 3 deletions lib/src/text_field/base_text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,22 @@ class BaseTextFieldState extends State<BaseTextField>
_formFieldKey.currentState?.validate();
}

void _onChanged(String value) {
// ignore: avoid_void_async
void _onChanged(String value) async {
if (_previousTextValue == value) return;

_previousTextValue = value;

widget.onChanged(value);

// we need to wait until the next microtask
await Future<void>.delayed(const Duration());

// ⚠️ validate after the new input is attached
// we always want to validate the new input when the current state is invalid
if (!_textFieldIsValid) {
_formFieldKey.currentState?.validate();
}

widget.onChanged(value);
}

void _addFocusNodeListener() {
Expand Down

0 comments on commit a13c9eb

Please sign in to comment.