Skip to content

showCupertinoModalPopup shows unexpected scrollbar #70771

Closed

Description

@edwin-alvarez

Having an extra scrollbar on my showCupertinoModalPopup which causes an internal flutter exception (All Exception Enabled) when the user clicks or drags it. Please see the image and the example code below:

Why does the dialog show scroll?, is there any way to remove it

Nov-18-2020 08-51-252

Example Flutter Code
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

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

  var _filterPhoneOptions = [
    'Option 1',
    'Option 2',
    'Option 3',
    'Option 4',
    'Option 5',
    'Option 6',
    'Option 7',
    'Option 8',
    'Option 9',
  ];

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Material App Bar'),
      ),
      body: Center(
        child: Container(
          padding: const EdgeInsets.symmetric(horizontal: 10),
          child: Text(
            'showCupertinoModalPopup + CupertinoPicker shows scroll on right top corner while user scrolls the CupertinoPicker. if user clicks the scrolls flutter throws an exeception.',
            textAlign: TextAlign.justify,
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton.extended(
        onPressed: () async {
          await showCupertinoModalPopup(
            semanticsDismissible: false,
            context: context,
            builder: (BuildContext cnt) {
              return StatefulBuilder(
                  builder: (BuildContext context, StateSetter setState) {
                return Material(
                  color: Colors.transparent,
                  child: CupertinoActionSheet(
                    title: Text("Some Title",
                        style: const TextStyle(
                          fontSize: 30,
                        )),
                    message: _buildPhoneFilter(),
                    actions: <Widget>[
                      CupertinoActionSheetAction(
                        child: Text("Confirm"),
                        onPressed: () {
                          Navigator.pop(context, 1);
                        },
                      ),
                    ],
                    cancelButton: CupertinoActionSheetAction(
                      isDefaultAction: true,
                      child: Text("Cancel"),
                      onPressed: () {
                        Navigator.pop(context, 0);
                      },
                    ),
                  ),
                );
              });
            },
          ) as int;
        },
        icon: Icon(Icons.add),
        label: Text('bottomsheet'),
      ),
    );
  }

  Widget _buildPhoneFilter() => ConstrainedBox(
        constraints: BoxConstraints(maxHeight: 48, maxWidth: 100),
        child: CupertinoPicker(
          scrollController: FixedExtentScrollController(),
          useMagnifier: true,
          magnification: 1,
          itemExtent: 40,
          onSelectedItemChanged: (int index) {
            currentSelectedNotification = index;
          },
          children: new List<Widget>.generate(_filterPhoneOptions.length,
              (int index) {
            return Center(
              child: Text(
                _filterPhoneOptions[index],
                overflow: TextOverflow.clip,
                style: TextStyle(
                    color: Colors.black,
                    fontSize: 15,
                    letterSpacing: -0.4,
                    fontWeight: FontWeight.w400),
              ),
            );
          }),
        ),
      );
}
flutter doctor -v flutter doctor -v ``` [✓] Flutter (Channel stable, 1.22.3, on Mac OS X 10.15.7 19H15, locale en-US) • Flutter version 1.22.3 at /Users/XXX/Documents/flutter • Framework revision 8874f21 (3 weeks ago), 2020-10-29 14:14:35 -0700 • Engine revision a1440ca392 • Dart version 2.10.3

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/XXX/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.

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

[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)

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

[✓] Connected device (1 available)
• iPhone 11 Pro (mobile) • CCDD6B4D-C6B0-48AF-8BE5-090E0403F2B8 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-14-2 (simulator)

</details>


  

Activity

  1. sidrao2006 commented on Nov 18, 2020

    @sidrao2006
    Contributor

    Hello @edwin-alvarez ,
    Could you please post the outputs of flutter run -v and flutter doctor -v?
    Thank you!

  2. changed the title [-]showCupertinoModalPopup scrollbar exception.[/-] [+]showCupertinoModalPopup shows not expected scrollbar[/+] on Nov 18, 2020
  3. edwin-alvarez commented on Nov 18, 2020

    @edwin-alvarez
    Author

    @sidrao2006 , updated.

  4. pedromassangocode commented on Nov 19, 2020

    @pedromassangocode

    gif

    flutter doctor -v
    [✓] Flutter (Channel master, 1.24.0-8.0.pre.304, on Mac OS X 10.15.7 19H2 darwin-x64, locale en)
        • Flutter version 1.24.0-8.0.pre.304 at /Users/pedromassango/dev/SDKs/flutter_master
        • Framework revision c6290500f8 (10 hours ago), 2020-11-18 17:29:28 -0800
        • Engine revision 35a0b9fe68
        • Dart version 2.12.0 (build 2.12.0-50.0.dev)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
        • Android SDK at /Users/pedromassango/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-6915495)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 12.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.1, Build version 12A7403
        • CocoaPods version 1.9.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.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 1.8.0_242-release-1644-b3-6915495)
    
    [✓] IntelliJ IDEA Community Edition (version 2020.2.3)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 51.0.3
        • Dart plugin version 202.8070
    
    [✓] VS Code (version 1.51.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.16.0
    
    [✓] Connected device (4 available)
        • iPhone 11 Pro Max (mobile) • 7A82F29E-E49E-4B3C-8609-1570361DBC17 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
        • 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.198
    
    • No issues found!
    
    
  5. added
    p: cupertino_ui
    f: inspector
    f: scrolling
    found in release: 1.24
    has reproducible steps
    on Nov 19, 2020
  6. edwin-alvarez commented on Nov 19, 2020

    @edwin-alvarez
    Author

    @pedromassangocode , thanks for also checking on 1.24. hope we can get some help to figure out why there is a scroll.

    Did you include your CupertinoPicker inside a Container(decoration:borderRadius) for the rounded shape?

  7. pedromassangocode commented on Nov 20, 2020

    @pedromassangocode

    Did you include your CupertinoPicker inside a Container(decoration:borderRadius) for the rounded shape?

    No, I just copy/pasted your code and ran it. Hmmm looks like there is a breaking change here.
    Cc @HansMuller

  8. added
    framework
    on Dec 4, 2020
  9. changed the title [-]showCupertinoModalPopup shows not expected scrollbar[/-] [+]showCupertinoModalPopup shows unexpected scrollbar[/+] on Dec 4, 2020
  10. simrat39 commented on Dec 24, 2020

    @simrat39

    This happens due to the same reason as #36474.

    To fix this you can handle the ScrollNotification right above the CupertinoPicker

    Widget _buildPhoneFilter() => ConstrainedBox(
           constraints: BoxConstraints(maxHeight: 48, maxWidth: 100),
           child: NotificationListener<ScrollNotification>(
             onNotification: (notification) => true,
             child: CupertinoPicker(
               scrollController: FixedExtentScrollController(),
               useMagnifier: true,
               magnification: 1,
               itemExtent: 40,
               onSelectedItemChanged: (int index) {
                 currentSelectedNotification = index;
               },
               children: new List<Widget>.generate(_filterPhoneOptions.length,
                   (int index) {
                 return Center(
                   child: Text(
                     _filterPhoneOptions[index],
                     overflow: TextOverflow.clip,
                     style: TextStyle(
                         color: Colors.black,
                         fontSize: 15,
                         letterSpacing: -0.4,
                         fontWeight: FontWeight.w400),
                   ),
                 );
               }),
             ),
           ),
         );
    

    cupertino_scrollbar_random

  11. xu-baolin commented on Dec 24, 2020

    @xu-baolin
    Member

    Can be fixed by #71843

  12. edwin-alvarez commented on Dec 30, 2020

    @edwin-alvarez
    Author

    I tried @simrat39 workaround and it worked 👍

  13. github-actions commented on Aug 7, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  14. locked as resolved and limited conversation to collaborators on Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: inspectorf: scrollingfound in release: 1.24frameworkhas reproducible stepsp: cupertino_ui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions