Skip to content

DropdownButton scrollbar is not clipped within the menu border radius #102914

@SuperPenguin

Description

@SuperPenguin

DropdownButton scrollbar is displayed beyond the menu list if border radius set with large value

Steps to Reproduce

  1. Run code below
  2. See the scrollbar goes beyond menu list

Expected results: scrollbar should be within inside dropdown menu (clipped)

Actual results: scrollbar is not clipped

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

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(const App());
}

class App extends StatelessWidget {
  const App({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        brightness: Brightness.light,
      ),
      home: const Home(),
    );
  }
}

class Home extends StatefulWidget {
  const Home({Key? key}) : super(key: key);

  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  int _value = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Dropdown'),
      ),
      body: Padding(
        padding: const EdgeInsets.symmetric(
          vertical: 8.0,
          horizontal: 16.0,
        ),
        child: Column(
          children: [
            Row(
              children: [
                const SizedBox(
                  width: 100,
                  child: Text('Leading'),
                ),
                Expanded(
                  child: MyDropdown(
                    value: _value,
                    onChanged: (value) {
                      if (value != null && value != _value) {
                        setState(() {
                          _value = value;
                        });
                      }
                    },
                  ),
                ),
                const SizedBox(
                  width: 100,
                  child: Text('Trailing'),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

class MyDropdown extends StatelessWidget {
  const MyDropdown({
    Key? key,
    required this.value,
    required this.onChanged,
  }) : super(key: key);

  final int value;
  final ValueChanged<int?> onChanged;

  @override
  Widget build(BuildContext context) {
    return DropdownButton<int>(
      isExpanded: true,
      onChanged: onChanged,
      value: value,
      borderRadius: const BorderRadius.all(
        Radius.circular(16.0),
      ),
      items: [
        for (int i = 0; i < 100; i++)
          DropdownMenuItem(
            value: i,
            child: Text(
              i.toString(),
            ),
          ),
      ],
    );
  }
}
Logs
[✓] Flutter (Channel unknown, 2.10.4, on macOS 12.3.1 21E258 darwin-arm, locale en-ID)
    • Flutter version 2.10.4 at /Users/s21/Documents/GitHub/flutter/flutter
    • Upstream repository unknown
    • Framework revision c860cba910 (5 weeks ago), 2022-03-25 00:23:12 -0500
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/s21/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

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

[✓] Android Studio (version 2021.1)
    • Android Studio at /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 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.66.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.38.1

[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64  • Android 12 (API 31) (emulator)
    • macOS (desktop)             • macos         • darwin-arm64   • macOS 12.3.1 21E258 darwin-arm
    • Chrome (web)                • chrome        • web-javascript • Google Chrome 101.0.4951.41

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Screen Shot 2022-05-02 at 14 22 00

Metadata

Metadata

Assignees

Labels

a: qualityA truly polished experiencef: material designflutter/packages/flutter/material repository.found in release: 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13frameworkflutter/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 version

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions