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

BoardDateTimeInputField onChanged No trigger #64

Open
fenqing168 opened this issue Jan 9, 2025 · 5 comments
Open

BoardDateTimeInputField onChanged No trigger #64

fenqing168 opened this issue Jan 9, 2025 · 5 comments

Comments

@fenqing168
Copy link

fenqing168 commented Jan 9, 2025

Dear author, thank you for your contribution to the flutter ecosystem

I encountered a problem while using it

Problem Reproduction

BoardDateTimeInputField's onChanged will not trigger

BoardDateTimeInputField(
  readOnly: true,
  decoration: InputDecoration(
    labelText: '开始时间',
    hintText: '请输入开始时间',
    border: const OutlineInputBorder(),
  },
  options: const BoardDateTimeOptions(
      languages: BoardPickerLanguages(
          today: '今天',
          tomorrow: '明天',
          yesterday: '昨天',
          now: '现在',
          locale: 'zh'
      ),
      inputable: false,
      useResetButton: true
  ),
  pickerType: DateTimePickerType.date,
  onChanged: (DateTime date) {
    setState(() {
      _form.startTime = date;
    });
  },
),

After looking at the source code, I found that the conditions for onChanged to start are quite strict. Can the conditions be relaxed?
image

@mytooyo
Copy link
Owner

mytooyo commented Jan 10, 2025

@fenqing168
Is it necessary for onChange to trigger a callback with each input?

@fenqing168
Copy link
Author

After testing, neither clicking the OK button nor sliding will trigger

@fenqing168
Copy link
Author

Because in the BoardDateTimeInputField source code, the condition on line 407 is false, which means that the TextFormField still has focus at this time

@mytooyo
Copy link
Owner

mytooyo commented Jan 10, 2025

@fenqing168
In my environment, onChange is being called.
Under what kind of operations is it not being triggered?

@fenqing168
Copy link
Author

I changed the implementation method and cannot provide a reproducible environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants