2
TextButton(
  onPressed: () => _showPicker(context),
  child: Icon(Icons.calendar_today),
)

Future<DateTime?> _showPicker(BuildContext context) {
  return showDatePicker(
      context: context, initialDate: DateTime(2000),
      firstDate: DateTime(1990),
      lastDate: DateTime(2100));
}

The DatePicker pops up, but when you try to select a date or year it throws: Expected a value of type 'String', but got one of type 'Null'

Flutter 2.0.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision 4d7946a68d (7 days ago) • 2021-03-18 17:24:33 -0700 Engine • revision 3459eb2436 Tools • Dart 2.12.2

3 Answers 3

1

EDIT: This has been fixed in the master channel and will release soon

I filed a bug for this: https://github.com/flutter/flutter/issues/79834

This is caused by the framework internally calling HapticFeedback.vibrate() for a fun little buzz when you tap pretty much anything in the pop-up window. However, on Web, this doesn't work. There is a switch-case to try to see if the platform supports it, but Web never got a proper TargetPlatform, so the code thinks computers can vibrate.

When Flutter tries sending a message to the web engine, the null error happens.

Sign up to request clarification or add additional context in comments.

2 Comments

I opened an issue too, but they were not able too reproduce it github.com/flutter/flutter/issues/79129
I checked it out, they fixed it already on the master channel, that's why they weren't able to reproduce it.
1

I see the same using the latest flutter for web. It looks like the error is within the datepicker itself, not my code? The datepicker still seems to function as expected despite the error message showing in the debug consol?.

1 Comment

Just tried it on a real phone and the error does not show, so it seems to be a web issue only. The answer from Levi Lesches seems right.
0

I use verison 2.2.3 stable, this issue has been fixed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.