Skip to content

DateRangePickerDialog crashes when currentDate is omitted #177441

@bleroux

Description

@bleroux

Steps to reproduce

  1. Run the code sample

Expected results

The DateRangePickerDialog content is shown

Actual results

Null check operator used on a null value

Code sample

Code sample
import 'package:flutter/material.dart';

void main() => runApp(const ReproApp());

class ReproApp extends StatelessWidget {
  const ReproApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Center(
        child: DateRangePickerDialog(
          firstDate: DateTime(2021),
          lastDate: DateTime(2031, DateTime.december, 31),
          initialEntryMode: DatePickerEntryMode.inputOnly,
        ),
      ),
    );
  }
}

Screenshots or Video

Logs

Logs
════════ Exception caught by widgets library ═══════════════════════════════════
The following _TypeError was thrown building _InputDateRangePickerDialog(dirty, dependencies: [InheritedCupertinoTheme, MediaQuery, _InheritedTheme, _LocalizationsScope-[GlobalKey#8240a]]):
Null check operator used on a null value

The relevant error-causing widget was:
    DateRangePickerDialog DateRangePickerDialog:file:///Users/bruno/Nevercode/Investigation/investigationapp/lib/0%20-%20Investigate/Material/DateAndTimePicker/flutter_177083/flutter_177083_report.dart:12:16

When the exception was thrown, this was the stack:
#0      _InputDateRangePickerDialog.build (package:flutter/src/material/date_picker.dart:3109:18)
date_picker.dart:3109
#1      StatelessElement.build (package:flutter/src/widgets/framework.dart:5892:49)
framework.dart:5892
#2      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5820:15)
framework.dart:5820

Flutter Doctor output

Doctor output
Flutter (Channel master, 3.38.0-1.0.pre-204, on macOS 15.6.1 24G90 darwin-arm64, locale en-FR)

Metadata

Metadata

Assignees

Labels

c: crashStack traces logged to the consolef: date/time pickerDate or time picker widgetsf: material designflutter/packages/flutter/material repository.found in release: 3.35Found to occur in 3.35found in release: 3.38Found to occur in 3.38frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions