Skip to content

DropdownMenu throws exception when nested inside two SingleChildScrollView #146764

@migueldeoleiros

Description

@migueldeoleiros

Steps to reproduce

  1. Add a DropdownMenu inside two SingleChildScrollView
  2. Run the debuger
  3. Try to writte something on the field that matches one of the menu entries

Expected results

It shouldn't throw an exception, the way it works if we delete the first SingleChildScrollView

Actual results

It throws renderer.parent != null is not true

Code sample

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

void main() {
  runApp(const MainApp());
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: SingleChildScrollView(
        child: Card(
          child: SingleChildScrollView(
            child: DropdownMenu<String>(
                enableFilter: true,
                requestFocusOnTap: true,
                label: Text("test"),
                dropdownMenuEntries: [
                  DropdownMenuEntry(value: "1", label: "one"),
                  DropdownMenuEntry(value: "2", label: "two"),
                ]),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

No response

Logs

Debug console output
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/rendering/object.dart': Failed assertion: line 3345 pos 14: 'renderer.parent != null': is not true.
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      RenderObject.getTransformTo (package:flutter/src/rendering/object.dart:3345:14)
#3      ScrollPosition.ensureVisible (package:flutter/src/widgets/scroll_position.dart:809:28)
#4      ScrollableState._performEnsureVisible (package:flutter/src/widgets/scrollable.dart:1041:55)
#5      Scrollable.ensureVisible (package:flutter/src/widgets/scrollable.dart:475:45)
#6      _DropdownMenuState.scrollToHighlight.<anonymous closure> (package:flutter/src/material/dropdown_menu.dart:450:20)
#7      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1386:15)
#8      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1322:11)
#9      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1169:5)
#10     _invoke (dart:ui/hooks.dart:312:13)
#11     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:399:5)
#12     _drawFrame (dart:ui/hooks.dart:283:31)

Flutter Doctor output

Doctor output
[✓] Flutter (Channel , 3.19.5, on Arch Linux 6.8.5-arch1-1, locale en_US.UTF-8)
    • Flutter version 3.19.5 on channel  at /usr/lib/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision archlinuxaur (unknown (arch linux aur package)), 2038-01-19
      03:14:08
    • Engine revision e76c95649884
    • Dart version 3.3.2
    • DevTools version 2.31.1

[✗] Android toolchain - develop for Android devices
    ✗ ANDROID_HOME = /opt/android-sdk
      but Android SDK not found at this location.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 17.0.6
    • cmake version 3.29.2
    • ninja version 1.11.1
    • pkg-config version 2.1.1

[✓] Android Studio (version 2023.1)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 77.2.1
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Arch Linux 6.8.5-arch1-1
    • Chrome (web)    • chrome • web-javascript • Google Chrome 123.0.6312.122

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

! Doctor found issues in 1 category.

Metadata

Metadata

Labels

P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworkc: regressionIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.found in release: 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-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