Skip to content

Non-nullable DropdownMenu is breaking change #180121

@Gustl22

Description

@Gustl22

Steps to reproduce

#175090 and PR #176711 does break current implementation, since: 3.39.0-0.1.pre

An example can be found here:
#176711 (comment)

Further the type safe part of #175090 (in my opinion) does raise more problems than it actually solves. I personally don't see removing the ambiguity has any real world scenarios. In contrast the need of a null value is actually used. I don't see a concrete issue with getting the same value can result from two different events does have a negative impact (why would someone want to differentiate that, and also with this change there is not even a built-in option to differentiate.

Expected results

To either:

Actual results

The changes are breaking the below example and are a valid approach to reflect empty selection: https://material-web.dev/components/select/#usage

There are already three cases which were mentioned to break (myself included).

Code sample

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

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Demo',
      home: Card(
        child: DropdownMenu<String?>(
          dropdownMenuEntries: [
            DropdownMenuEntry(value: null, label: 'Label'),
            DropdownMenuEntry(value: '1', label: '1'),
            DropdownMenuEntry(value: '2', label: '2'),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work listc: regressionIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.found in release: 3.40Found to occur in 3.40frameworkflutter/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 teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions