Repository: flutter
Issue: [web] `showDatePicker` on web shows an error when date selected and uncaught exceptions is turned ON
Labels: engine,f: date/time picker,a: debugging,platform-web,a: error message,has reproducible steps,P2,found in release: 2.3,team-web,triaged-web

## Steps to Reproduce

Create a default flutter project. Replace the code in the `main.dart` with the below:

```dart
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final String? title;

  MyHomePage({Key? key, this.title}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title!)),
      body: Center(
        child: MaterialButton(
          onPressed: () async {
            DateTime? _d = await showDatePicker(
              context: context,
              initialDate: DateTime.now(),
              firstDate: DateTime.now(),
              lastDate: DateTime.now(),
            );
            if (_d != null) {
              print(_d);
              ScaffoldMessenger.of(context).showSnackBar(
                  SnackBar(content: Text('$_d is the selected date')));
            }
          },
          child: Text('Select Date'),
        ),
      ),
    );
  }
}
```

Once `main.dart` is replaced, run the app on WEB. This issue can only be found on the web.

**Expected results:** <!-- what did you want to see? -->
Nothing gets dumped to the console.

**Actual results:** <!-- what did you see? -->
If uncaught exceptions is turned on, the app stops and I get the error. However, if it is off, it all gets thrown in the console. The error that gets thrown in the console is below in the logs section:

<details>
  <summary>Logs</summary>

```
Launching lib\main.dart on Chrome in debug mode...
Debug service listening on ws://127.0.0.1:53341/upnvNjJs6tc=/ws
💪 Running with sound null safety 💪
Connecting to VM Service at ws://127.0.0.1:53341/upnvNjJs6tc=/ws
Error: Expected a value of type 'String', but got one of type 'Null'
    at Object.throw_ [as throw] (http://localhost:53170/dart_sdk.js:5031:11)
    at Object.castError (http://localhost:53170/dart_sdk.js:5004:15)
    at Object.cast [as as] (http://localhost:53170/dart_sdk.js:5313:17)
    at Function.as (http://localhost:53170/dart_sdk.js:42399:19)
    at _engine.EnginePlatformDispatcher.__.[_sendPlatformMessage] (http://localhost:53170/dart_sdk.js:155296:38)
    at _engine.EnginePlatformDispatcher.__.sendPlatformMessage (http://localhost:53170/dart_sdk.js:155212:33)
    at _DefaultBinaryMessenger.[_sendPlatformMessage] (http://localhost:53170/packages/flutter/src/services/system_channels.dart.lib.js:2180:38)
    at _DefaultBinaryMessenger.send (http://localhost:53170/packages/flutter/src/services/system_channels.dart.lib.js:2224:40)
    at OptionalMethodChannel._invokeMethod (http://localhost:53170/packages/flutter/src/services/system_channels.dart.lib.js:948:50)
    at _invokeMethod.next (<anonymous>)
    at runBody (http://localhost:53170/dart_sdk.js:37228:34)
    at Object._async [as async] (http://localhost:53170/dart_sdk.js:37259:7)
    at OptionalMethodChannel.[_invokeMethod] (http://localhost:53170/packages/flutter/src/services/system_channels.dart.lib.js:946:20)
    at OptionalMethodChannel.[_invokeMethod] (http://localhost:53170/packages/flutter/src/services/system_channels.dart.lib.js:1078:34)
    at OptionalMethodChannel.invokeMethod (http://localhost:53170/packages/flutter/src/services/system_channels.dart.lib.js:1056:36)
    at invokeMethod.next (<anonymous>)
    at runBody (http://localhost:53170/dart_sdk.js:37228:34)
    at Object._async [as async] (http://localhost:53170/dart_sdk.js:37259:7)
    at OptionalMethodChannel.invokeMethod (http://localhost:53170/packages/flutter/src/services/system_channels.dart.lib.js:1055:20)
    at vibrate (http://localhost:53170/packages/flutter/src/services/haptic_feedback.dart.lib.js:30:55)
    at vibrate.next (<anonymous>)
    at runBody (http://localhost:53170/dart_sdk.js:37228:34)
    at Object._async [as async] (http://localhost:53170/dart_sdk.js:37259:7)
    at Function.vibrate (http://localhost:53170/packages/flutter/src/services/haptic_feedback.dart.lib.js:29:20)
    at calendar_date_picker._CalendarDatePickerState.new.[_vibrate] (http://localhost:53170/packages/flutter/src/material/calendar_date_picker.dart.lib.js:2654:42)
    at calendar_date_picker._CalendarDatePickerState.new.[_handleDayChanged] (http://localhost:53170/packages/flutter/src/material/calendar_date_picker.dart.lib.js:2702:21)
    at calendar_date_picker._MonthPickerState.new.[_handleDateSelected] (http://localhost:53170/packages/flutter/src/material/calendar_date_picker.dart.lib.js:3130:11)
    at http://localhost:53170/packages/flutter/src/material/calendar_date_picker.dart.lib.js:3539:28
    at ink_well._InkResponseState.new.[_handleTap] (http://localhost:53170/packages/flutter/src/material/icon_button.dart.lib.js:50084:42)
    at tap.TapGestureRecognizer.new.invokeCallback (http://localhost:53170/packages/flutter/src/gestures/recognizer.dart.lib.js:201:18)
    at tap.TapGestureRecognizer.new.handleTapUp (http://localhost:53170/packages/flutter/src/gestures/tap.dart.lib.js:417:40)
    at tap.TapGestureRecognizer.new.[_checkUp] (http://localhost:53170/packages/flutter/src/gestures/tap.dart.lib.js:223:12)
    at tap.TapGestureRecognizer.new.handlePrimaryPointer (http://localhost:53170/packages/flutter/src/gestures/tap.dart.lib.js:169:23)
    at tap.TapGestureRecognizer.new.handleEvent (http://localhost:53170/packages/flutter/src/gestures/recognizer.dart.lib.js:456:16)
    at pointer_router.PointerRouter.new.[_dispatch] (http://localhost:53170/packages/flutter/src/gestures/pointer_router.dart.lib.js:103:9)
    at http://localhost:53170/packages/flutter/src/gestures/pointer_router.dart.lib.js:138:26
    at LinkedMap.new.forEach (http://localhost:53170/dart_sdk.js:25047:11)
    at pointer_router.PointerRouter.new.[_dispatchEventToRoutes] (http://localhost:53170/packages/flutter/src/gestures/pointer_router.dart.lib.js:135:29)
    at pointer_router.PointerRouter.new.route (http://localhost:53170/packages/flutter/src/gestures/pointer_router.dart.lib.js:127:37)
    at binding$5.WidgetsFlutterBinding.new.handleEvent (http://localhost:53170/packages/flutter/src/gestures/binding.dart.lib.js:330:26)
    at binding$5.WidgetsFlutterBinding.new.dispatchEvent (http://localhost:53170/packages/flutter/src/gestures/binding.dart.lib.js:313:24)
    at binding$5.WidgetsFlutterBinding.new.dispatchEvent (http://localhost:53170/packages/flutter/src/rendering/layer.dart.lib.js:6071:13)
    at binding$5.WidgetsFlutterBinding.new.[_handlePointerEventImmediately] (http://localhost:53170/packages/flutter/src/gestures/binding.dart.lib.js:284:14)
    at binding$5.WidgetsFlutterBinding.new.handlePointerEvent (http://localhost:53170/packages/flutter/src/gestures/binding.dart.lib.js:257:43)
    at binding$5.WidgetsFlutterBinding.new.[_flushPointerEventQueue] (http://localhost:53170/packages/flutter/src/gestures/binding.dart.lib.js:246:14)
    at binding$5.WidgetsFlutterBinding.new.[_handlePointerDataPacket] (http://localhost:53170/packages/flutter/src/gestures/binding.dart.lib.js:236:65)
    at Object.invoke1 (http://localhost:53170/dart_sdk.js:173274:7)
    at _engine.EnginePlatformDispatcher.__.invokeOnPointerDataPacket (http://localhost:53170/dart_sdk.js:155199:15)
    at _engine.PointerBinding.__.[_onPointerData] (http://localhost:53170/dart_sdk.js:155813:49)
    at http://localhost:53170/dart_sdk.js:156230:28
    at http://localhost:53170/dart_sdk.js:156186:16
    at http://localhost:53170/dart_sdk.js:155906:11

```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
Analyzing app...                                                        
No issues found! (ran in 11.0s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 2.0.6, on Microsoft Windows [Version 10.0.19042.928], locale en-US)
    • Flutter version 2.0.6 at C:\src\flutter
    • Framework revision 1d9032c7e1 (13 days ago), 2021-04-29 17:37:58 -0700
    • Engine revision 05e680e202
    • Dart version 2.12.3
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\ziyad\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.4)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.9.31205.134
    • Windows 10 SDK version 10.0.19041.0

[✓] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[✓] VS Code (version 1.56.1)
    • VS Code at C:\Users\ziyad\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.22.0

[✓] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19042.928]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 90.0.4430.93
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 90.0.818.56

• No issues found!
```

</details>