[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DropdownButton very slow on first opening #68017

Open
Pe-te opened this issue Oct 13, 2020 · 19 comments
Open

DropdownButton very slow on first opening #68017

Pe-te opened this issue Oct 13, 2020 · 19 comments
Labels
a: quality A truly polished experience c: performance Relates to speed or footprint issues (see "perf:" labels) f: material design flutter/packages/flutter/material repository. found in release: 3.3 Found to occur in 3.3 found in release: 3.7 Found to occur in 3.7 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on team-design Owned by Design Languages team triaged-design Triaged by Design Languages team

Comments

@Pe-te
Copy link
Pe-te commented Oct 13, 2020

When using a DropdownButton for the first time, it is very slow, the opening of list takes around 3 seconds.
After that the dropdown opens immediately every time I try.

I think it takes very long to layout the items and later on they are cached? But it's only 30 items in my list? Even with 3000 items the delay seems to be the same, so not sure where it might come from.

Here's a minimal example, I just created a fresh flutter project with Android Studio and put this in the children array.

DropdownButton(
  hint: Text("XYZ"),
  value: 0,
  items: List<DropdownMenuItem>.generate(3000, (int index) => DropdownMenuItem(
    value: index,
    child: Text("Item "+index.toString()),
  )),
  onChanged: (value) {
    log(value.toString());
  },
),

Is that delay expected? Any solution like pre-rendering or loading the DropdownMenuItems on the fly instead of using toList()?

@pedromassangocode
Copy link

Hi @Pe-te
Can you please provide your flutter doctor -v?
Thank you

@pedromassangocode pedromassangocode added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Oct 13, 2020
@Pe-te
Copy link
Author
Pe-te commented Oct 13, 2020

Sure, upgraded yesterday in master branch. I'm testing on iOS 14 iPads (simulator and device) right now, not sure if other versions are affected.

> flutter doctor -v
[✓] Flutter (Channel master, 1.23.0-14.0.pre.111, on Mac OS X 10.15.7 19H2 x86_64, locale de)
    • Flutter version 1.23.0-14.0.pre.111 at /Users/pete/.fluttersdk
    • Framework revision 8211aaa2ae (vor 29 Stunden), 2020-10-12 17:25:38 +0800
    • Engine revision 11d756a62e
    • Dart version 2.11.0 (build 2.11.0-207.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/pete/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.9.3

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 50.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

• No issues found!

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 13, 2020
@Pe-te
Copy link
Author
Pe-te commented Oct 13, 2020

Have added a better example in the question. Thanks for looking into it!

@chinmoy12c
Copy link
Member
chinmoy12c commented Oct 13, 2020

I'm able to able to reproduce this issue Android 10 device, although the lag is about 2 seconds long even with 1 item in the list
.

@HansMuller HansMuller added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Oct 13, 2020
@pedromassangocode
Copy link

I'm able to reproduce as well. There is a considerable delay on first opening.

gif

This is the onTap method being called:

void _handleTap() {
final RenderBox itemBox = context.findRenderObject()! as RenderBox;
final Rect itemRect = itemBox.localToGlobal(Offset.zero) & itemBox.size;
final TextDirection? textDirection = Directionality.of(context);
final EdgeInsetsGeometry menuMargin = ButtonTheme.of(context).alignedDropdown
? _kAlignedMenuMargin
: _kUnalignedMenuMargin;
final List<_MenuItem<T>> menuItems = <_MenuItem<T>>[
for (int index = 0; index < widget.items!.length; index += 1)
_MenuItem<T>(
item: widget.items![index],
onLayout: (Size size) {
// If [_dropdownRoute] is null and onLayout is called, this means
// that performLayout was called on a _DropdownRoute that has not
// left the widget tree but is already on its way out.
//
// Since onLayout is used primarily to collect the desired heights
// of each menu item before laying them out, not having the _DropdownRoute
// collect each item's height to lay out is fine since the route is
// already on its way out.
if (_dropdownRoute == null)
return;
_dropdownRoute!.itemHeights[index] = size.height;
},
)
];
assert(_dropdownRoute == null);
_dropdownRoute = _DropdownRoute<T>(
items: menuItems,
buttonRect: menuMargin.resolve(textDirection).inflateRect(itemRect),
padding: _kMenuItemPadding.resolve(textDirection),
selectedIndex: _selectedIndex ?? 0,
elevation: widget.elevation,
theme: Theme.of(context, shadowThemeOnly: true),
style: _textStyle!,
barrierLabel: MaterialLocalizations.of(context)!.modalBarrierDismissLabel,
itemHeight: widget.itemHeight,
dropdownColor: widget.dropdownColor,
);
Navigator.push(context, _dropdownRoute!).then<void>((_DropdownRouteResult<T>? newValue) {
_removeDropdownRoute();
if (!mounted || newValue == null)
return;
if (widget.onChanged != null)
widget.onChanged!(newValue.result);
});
if (widget.onTap != null) {
widget.onTap!();
}
}

Complete code sample
import 'package:flutter/material.dart';

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

/// This is the main application widget.
class MyApp extends StatelessWidget {
  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: Center(
          child: DropdownButton<String>(
            value: 'One',
            onChanged: (String? newValue) {
            },
            items: <String>['One', 'Two', 'tree', 'Four']
                .map<DropdownMenuItem<String>>((String value) {
              return DropdownMenuItem<String>(
                value: value,
                child: Text(value),
              );
            }).toList(),
          ), //MyStatefulWidget(),
        ),
      ),
    );
  }
}
flutter doctor -v
[✓] Flutter (Channel master, 1.23.0-19.0.pre.20, on Mac OS X 10.15.7 19H2 darwin-x64, locale en)
    • Flutter version 1.23.0-19.0.pre.20 at /Users/pedromassango/dev/SDKs/flutter_master
    • Framework revision 66cf8d47a3 (88 minutes ago), 2020-10-14 14:47:28 +0900
    • Engine revision adf5b59485
    • Dart version 2.11.0 (build 2.11.0-217.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    • Android SDK at /Users/pedromassango/Library/Android/sdk
    • Platform android-30, build-tools 30.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.9.3

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

[✓] Android Studio (version 4.0)
    • 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 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Community Edition (version 2020.2.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin installed
    • Dart plugin version 202.7319.5

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

[✓] Connected device (4 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 10 (API 29)
      (emulator)
    • macOS (desktop)                    • macos         • darwin-x64     • Mac OS X 10.15.7 19H2
      darwin-x64
    • Web Server (web)                   • web-server    • web-javascript • Flutter Tools
    • Chrome (web)                       • chrome        • web-javascript • Google Chrome
      86.0.4240.80

• No issues found!

@pedromassangocode pedromassangocode added found in release: 1.23 Found to occur in 1.23 has reproducible steps The issue has been confirmed reproducible and is ready to work on a: quality A truly polished experience c: performance Relates to speed or footprint issues (see "perf:" labels) and removed in triage Presently being triaged by the triage team labels Oct 14, 2020
@bf
Copy link
bf commented Mar 23, 2021

Yeah so this is still observable in chrome and linux versions.

@dxvid-pts
Copy link

@Hixie this is another case of early-onset jank. You should consider adding this to the list.

@michalowskil
Copy link

Three static items in the list and first opening is lagging. It's not a 3 seconds. It's about one extra second on first opening.

@radha1990kumari
Copy link
radha1990kumari commented Jul 14, 2021

@Hixie ,Same issue , any alternative or work around for this .

@Hixie Hixie added this to Specific reports (new) in Early-onset jank Sep 10, 2021
@Hixie
Copy link
Contributor
Hixie commented Sep 10, 2021

Looks like it's shader jank; two frames back to back when opening the dropdown each have a bunch of shader compilations happening. (You can see this by running flutter run --profile and then opening the devtools; the frames with shader jank are marked in red.)

I recommend trying shader warm-up for now; since there's no subsequent frames with jank, it looks like we get all of the shaders in those two frames. Long term, #77412 is intended to be our permanent solution to this, but that'll take some time yet.

@Hixie Hixie moved this from Specific reports (new) to Specific reports (with test) in Early-onset jank Sep 10, 2021
@TahaTesser TahaTesser added the engine flutter/engine repository. See also e: labels. label Dec 13, 2021
@pinpong
Copy link
pinpong commented Jul 23, 2022

+1

@maheshmnj
Copy link
Member
maheshmnj commented Dec 29, 2022

I verified the issue on stable and master channels and it seems to render the list almost instantly.

Screen.Recording.2022-12-28.at.9.57.43.PM.mov
flutter doctor -v (mac)
[✓] Flutter (Channel master, 3.7.0-3.0.pre.33, on macOS 12.6 21G115 darwin-arm64, locale en-IN)
    • Flutter version 3.7.0-3.0.pre.33 on channel master 
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5201856805 (38 minutes ago), 2022-12-05 18:27:21 -0800
    • Engine revision a309d239c4
    • Dart version 2.19.0 (build 2.19.0-463.0.dev)
    • DevTools version 2.20.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly
      to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0-rc4
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.2)
    • 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.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

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

[✓] Connected device (3 available)
    • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.6 21G115 darwin-arm64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 108.0.5359.94

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

• No issues found!
[✓] Flutter (Channel stable, 3.3.9, on macOS 12.6 21G115 darwin-arm, locale en-IN)
    • Flutter version 3.3.9 on channel stable at /Users/mahesh/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b8f7f1f986 (24 hours ago), 2022-11-23 06:43:51 +0900
    • Engine revision 8f2221fbef
    • Dart version 2.18.5
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0-rc4
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.2)
    • 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.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

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

[✓] Connected device (3 available)
    • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.6 21G115 darwin-arm
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 107.0.5304.110

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

• No issues found!

Closing this issue for now. In case anyone is still encountering the issue, Please feel free to write in the comments and we will reopen it.

@maheshmnj maheshmnj added the r: fixed Issue is closed as already fixed in a newer version label Dec 29, 2022
@mrgzi
Copy link
mrgzi commented Jan 2, 2023

Are you sure this is fixed? I am still having the issue with 4000 items. But soon I will test again and inform you.

@michalowskil
Copy link

@maheshmnj I experienced the problem with responsiveness on Android and an Android emulator. In your video it looks like Web.

Also, I'd like to remind you that this problem occurred the first time the list was expanded. Subsequent expansions worked correctly.

@mgazisalik Please let us know.

@maheshmnj
Copy link
Member

I do see a little lag though when opening DropDown items for the first time, verified with 6000 items in the list.
Reopening!

Screen.Recording.2023-01-02.at.6.36.59.PM.mov
code sample
import 'package:flutter/material.dart';

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

/// This is the main application widget.
class MyApp extends StatelessWidget {
  static const String _title = 'Flutter Code Sample';

  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    final list = List.generate(1000, (index) => 'Item $index').toList();
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: Center(
          child: DropdownButton<String>(
            value: 'Item 1',
            onChanged: (String? newValue) {},
            items: List.generate(6000, (index) => 'Item $index')
                .toList()
                .map<DropdownMenuItem<String>>((String value) {
              return DropdownMenuItem<String>(
                value: value,
                child: Text(value),
              );
            }).toList(),
          ), //MyStatefulWidget(),
        ),
      ),
    );
  }
}
flutter doctor -v (mac)
[✓] Flutter (Channel master, 3.7.0-13.0.pre.131, on macOS 13.1 22C65 darwin-arm64, locale en-IN)
    • Flutter version 3.7.0-13.0.pre.131 on channel master at /Users/mahesh/Development/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 0196e6050b (2 days ago), 2022-12-31 11:10:23 -0500
    • Engine revision 932591ec04
    • Dart version 3.0.0 (build 3.0.0-76.0.dev)
    • DevTools version 2.20.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks
      and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0-rc4
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.2)
    • 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.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

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

[✓] Connected device (3 available)
    • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 13.1 22C65 darwin-arm64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 108.0.5359.124

[✓] HTTP Host Availability
    • All required HTTP hosts are available
    
• No issues found!
[✓] Flutter (Channel stable, 3.3.9, on macOS 12.6 21G115 darwin-arm, locale en-IN)
    • Flutter version 3.3.9 on channel stable at /Users/mahesh/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b8f7f1f986 (24 hours ago), 2022-11-23 06:43:51 +0900
    • Engine revision 8f2221fbef
    • Dart version 2.18.5
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0-rc4
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.2)
    • 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.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

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

[✓] Connected device (3 available)
    • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.6 21G115 darwin-arm
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 107.0.5304.110

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

• No issues found!

@maheshmnj maheshmnj reopened this Jan 2, 2023
@maheshmnj maheshmnj added found in release: 3.3 Found to occur in 3.3 found in release: 3.7 Found to occur in 3.7 and removed found in release: 1.23 Found to occur in 1.23 r: fixed Issue is closed as already fixed in a newer version labels Jan 2, 2023
@mrgzi
Copy link
mrgzi commented Jan 3, 2023

I do see a little lag though when opening DropDown items for the first time, verified with 6000 items in the list. Reopening!

Screen.Recording.2023-01-02.at.6.36.59.PM.mov
code sample
flutter doctor -v (mac)

Well, now I understand how you look at the issue. You are using just one screen and when you open the app, the dropdown is already rendered. How about creating two screens A and B and putting the dropdown widget on the B screen? In this case, if you are using page transition animation, when you try to go from A to B, you will see there will be a lag in the animation.

@maheshmnj
Copy link
Member

Well, now I understand how you look at the issue. You are using just one screen and when you open the app, the dropdown is already rendered. How about creating two screens A and B and putting the dropdown widget on the B screen? In this case, if you are using page transition animation, when you try to go from A to B, you will see there will be a lag in the animation.

Yes @mgazisalik, I do see a significant lag in this case

Screen.Recording.2023-01-03.at.4.35.33.PM.mov
code sample
import 'package:flutter/material.dart';

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

/// This is the main application widget.
class MyApp extends StatelessWidget {
  static const String _title = 'Flutter Code Sample';

  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(title: _title, home: HomePage());
  }
}

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Center(
            child: ElevatedButton(
                onPressed: () {
                  Navigator.of(context).push(
                      MaterialPageRoute(builder: (context) => const NewPage()));
                },
                child: const Text('tap me'))));
  }
}

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

  @override
  State<NewPage> createState() => _NewPageState();
}

class _NewPageState extends State<NewPage> {
  @override
  Widget build(BuildContext context) {
    final list = List.generate(6000, (index) => 'Item $index').toList();
    return Scaffold(
      appBar: AppBar(title: const Text('title')),
      body: Center(
        child: DropdownButton<String>(
          value: 'Item 1',
          onChanged: (String? newValue) {},
          items: List.generate(6000, (index) => 'Item $index')
              .toList()
              .map<DropdownMenuItem<String>>((String value) {
            return DropdownMenuItem<String>(
              value: value,
              child: Text(value),
            );
          }).toList(),
        ), //MyStatefulWidget(),
      ),
    );
  }
}

@TahaTesser TahaTesser removed the engine flutter/engine repository. See also e: labels. label May 3, 2023
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-design Owned by Design Languages team triaged-design Triaged by Design Languages team labels Jul 8, 2023
@siva636
Copy link
siva636 commented Aug 18, 2023

I can confirm that this issue still persists on Flutter 3.13 as well.

@ammar629
Copy link
ammar629 commented Apr 3, 2024

The issue still persists

Flutter 3.16.7 • channel stable • https://github.com/flutter/flutter.git  
Framework • revision ef1af02aea (3 months ago) • 2024-01-11 15:19:26 -0600
Engine • revision 4a585b7929
Tools • Dart 3.2.4 • DevTools 2.28.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: quality A truly polished experience c: performance Relates to speed or footprint issues (see "perf:" labels) f: material design flutter/packages/flutter/material repository. found in release: 3.3 Found to occur in 3.3 found in release: 3.7 Found to occur in 3.7 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on team-design Owned by Design Languages team triaged-design Triaged by Design Languages team
Projects
Early-onset jank
Specific reports (with test)
Development

No branches or pull requests