Skip to content

DropdownButton touchscreen selection blanks iPhone web browser screen when SemanticsBinding.instance.EnsureSemantics() is enabled #172180

@rhenley-aetna

Description

@rhenley-aetna

Steps to reproduce

  1. Create a Flutter Web app that enables SemanticsBinding.instance.ensureSemantics() and uses DropdownButton or DropdownButtonFormField.
  2. Deploy the app to an iOS (iPhone) web browser.
  3. Make a touchscreen (or mouse) selection of an item from any DropdownButton or DropdownButtonFormField dropdown overlay.

Expected results

The selected item would appear in the DropdownButton or DropdownButtonFormField selector. The rest of the app screen would adjust appropriately to the changed state.

Actual results

The selected item does appear in the DropdownButton or DropdownButtonFormField selector. The rest of the app screen does adjust appropriately to the changed state. And then the entire screen appears to slide right entirely off-screen, leaving the screen blank.

Code sample

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

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  // If the following line is removed, DropdownButton works properly.
  SemanticsBinding.instance.ensureSemantics();
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: DropdownExample()
        ),
      ),
    );
  }
}

class DropdownExample extends StatefulWidget {
  const DropdownExample({super.key});

  @override
  State<DropdownExample> createState() => _DropdownExampleState();
}

class _DropdownExampleState extends State<DropdownExample> {
  final TextEditingController _valueController1 = TextEditingController();
  String _selectedValue2 = "One";
  String _selectedValue3 = "One";

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(16.0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        spacing: 8,
        children: [
          Flexible(
              child: Text(
                  'When deployed to Flutter Web on an iPhone browser with ensureSemantics(), selecting from a DropdownButton or DropdownButtonFormField with touchscreen or mouse will cause the screen to blank out. Selection from the keyboard and VoiceOver work fine. DropdownMenu works fine, as do the other widgets when ensureSemantics is not set.'
              )
          ),
          Divider(),

          // Example 1: DropdownMenu widget work properly whether ensureSemantics
          // is enabled or not.
          Text('Example 1: DropdownMenu'),
          DropdownMenu(
              dropdownMenuEntries: ['One', 'Two', 'Three']
                  .map(
                    (String value) =>
                      DropdownMenuEntry<String>(value: value, label: value),
                  )
                  .toList(),
            controller: _valueController1,
            initialSelection: 'One',
          ),
          Divider(),

          // Example 2: DropdownButton
          // Selecting an item from a DropdownButton widget pop-up overlay with
          // the touchscreen or mouse causes the screen to blank on iPhone web
          // browsers when ensureSemantics is enabled. Keyboard and VoiceOver
          // selection work fine. DropdownButton touchscreen selection works
          // properly when ensureSemantics is not enabled.
          Text('Example 2: DropdownButton'),
          DropdownButton<String>(
            dropdownColor: Colors.amber,
            items: ['One', 'Two', 'Three']
                .map(
                  (value) =>
                  DropdownMenuItem(value: value, child: Text(value)),
            )
                .toList(),
            value: _selectedValue2,
            onChanged: (value) {
              setState(() {
                _selectedValue2 = value!;
              });
            },
          ),
          Divider(),

          // Example 3: DropdownButtonFormField
          // Like DropdownButton, selecting an item from a
          // DropdownButtonFormField widget pop-up overlay with the touchscreen
          // or mouse causes the screen to blank on iPhone web browsers when
          // ensureSemantics is enabled. Keyboard and VoiceOver selection work
          // fine. DropdownButtonFormField touchscreen selection works properly
          // when ensureSemantics is not enabled.
          Text('Example 3: DropdownFormField'),
          DropdownButtonFormField<String>(
            dropdownColor: Colors.amber,
            items: ['One', 'Two', 'Three']
                .map(
                  (value) =>
                  DropdownMenuItem(value: value, child: Text(value)),
            )
                .toList(),
            value: _selectedValue3,
            onChanged: (value) {
              setState(() {
                _selectedValue3 = value!;
              });
            },
          ),
        ],
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-07-15.at.16.00.47.mp4

Logs

Logs
$ flutter logs
Connected devices:
iPhone 16 Pro (mobile)   • BD35CEAD-D489-41F8-B36E-E0861A1FF37D     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-2 (simulator)
macOS (desktop)          • macos                                    • darwin-arm64   • macOS 15.5 24F74 darwin-arm64
Chrome (web)             • chrome                                   • web-javascript • Google Chrome 138.0.7204.101

No wireless devices were found.

[1]: iPhone 16 Pro (BD35CEAD-D489-41F8-B36E-E0861A1FF37D)
[2]: macOS (macos)
[3]: Chrome (chrome)
Please choose one (or "q" to quit): 3
Showing Instance of 'NoOpDeviceLogReader' logs:

Flutter Doctor output

Doctor output
$ flutter doctor -v
[✓] Flutter (Channel stable, 3.32.4, on macOS 15.5 24F74 darwin-arm64, locale en-US) [2.3s]
    • Flutter version 3.32.4 on channel stable at /Users/XXXXXXX/development/flutter
    • Upstream repository ssh://[email protected]/flutter/flutter.git
    • Framework revision 6fba2447e9 (5 weeks ago), 2025-06-12 19:03:56 -0700
    • Engine revision 8cd19e509d
    • Dart version 3.8.1
    • DevTools version 2.45.1

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0-rc5) [4.9s]
    • Android SDK at /Users/XXXXXXX/Library/Android/Sdk
    • Platform android-36, build-tools 36.0.0-rc5
    • ANDROID_HOME = /Users/XXXXXXX/Library/Android/Sdk
    • ANDROID_SDK_ROOT = /Users/XXXXXXX/Library/Sdk
    • Java binary at: /Users/XXXXXXX/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 16.4) [3.9s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16F6
    ✗ CocoaPods installed but not working.
        You appear to have CocoaPods installed but it is not working.
        This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
        This can usually be fixed by re-installing CocoaPods.
      For re-installation instructions, see https://guides.cocoapods.org/using/getting-started.html#installation

[✓] Chrome - develop for the web [42ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2025.1) [41ms]
    • Android Studio at /Users/XXXXXXX/Applications/Android Studio.app/Contents
    • 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 21.0.6+-13391695-b895.109)

[✓] IntelliJ IDEA Community Edition (version 2024.3.1.1) [40ms]
    • IntelliJ at /Users/XXXXXXX/Applications/IntelliJ IDEA Community Edition.app
    • 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

[✓] Connected device (3 available) [6.5s]
    • iPhone 16 Pro (mobile)   • BD35CEAD-D489-41F8-B36E-E0861A1FF37D     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-2 (simulator)
    • macOS (desktop)          • macos                                    • darwin-arm64   • macOS 15.5 24F74 darwin-arm64
    • Chrome (web)             • chrome                                   • web-javascript • Google Chrome 138.0.7204.101

[✓] Network resources [297ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)browser: chrome-iosonly manifests in Chrome on iOSbrowser: safari-iosonly manifests in Safari on iOScustomer: castawayf: material designflutter/packages/flutter/material repository.found in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-webOwned by Web platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions