Skip to content

Cupertino widgets don't change mouse cursor when hover on web #86174

Closed

Description

@jkevingutierrez

Steps to Reproduce

  1. Run flutter create bug.
  2. Add a CupertinoButton to the app. eg:

main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Bug'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              CupertinoButton(
                onPressed: () {
                  print('Cupertino');
                },
                child: const Text('Click me'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
  1. Run the app in the browser using Flutter web (flutter run -d chrome)
  2. Hover the CupertinoButton
  3. It won't change the cursor to indicate that it is a clickable element (SystemMouseCursors.click)
  4. You can also add a Material button, like a TextButton to compare the behavior:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Bug'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              CupertinoButton(
                onPressed: () {
                  print('Cupertino');
                },
                child: const Text('Click me'),
              ),
              TextButton(
                onPressed: () {
                  print('Material');
                },
                child: const Text('Click me'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

The problem can also be seen in https://flutter-widget.live/

For example

https://flutter-widget.live/widgets/CupertinoButton vs https://flutter-widget.live/widgets/RaisedButton
https://flutter-widget.live/widgets/CupertinoAlertDialog vs https://flutter-widget.live/widgets/AlertDialog
https://flutter-widget.live/widgets/CupertinoNavigationBar vs https://flutter-widget.live/widgets/AppBar

Visiting the site using a desktop browser and hovering the Cupertino clickable widgets, like the CupertinoButton will show the issue.

Cupertino clickable widgets (buttons) don't change the cursor to SystemMouseCursors.click, while material buttons change the cursor correctly.

Expected results:
In Flutter web, hovering Cupertino widgets that are clickable, like CuperttinoButton, CupertinoDialogAction, CupertinoNavigationBarBackButton, CupertinoActionSheetAction, etc, should show the cursor as clickable (SystemMouseCursors.click)

Actual results:
In the Flutter web, hovering Cupertino widgets that are clickable, like CuperttinoButton, CupertinoDialogAction, CupertinoNavigationBarBackButton, CupertinoActionSheetAction, etc, is showing the cursor as basic(SystemMouseCursors.basic)

Note: similar behavior is happening when the CupertinoButton is disabled (onPressed: null), it won't change the cursor to SystemMouseCursors.forbidden when the button is hovered. eg:

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Bug'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              CupertinoButton(
                onPressed: null,
                child: const Text('Click me'),
              ),
              TextButton(
                onPressed: null,
                child: const Text('Click me'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Activity

  1. changed the title [-]Most of Cupertino buttons in web don't change the cursor on hover to SystemMouserCursors.click[/-] [+]Most of Cupertino buttons in web don't change the cursor on hover to SystemMouseCursors.click[/+] on Jul 9, 2021
  2. changed the title [-]Most of Cupertino buttons in web don't change the cursor on hover to SystemMouseCursors.click[/-] [+]Most of Cupertino buttons in web don't change the cursor on hover[/+] on Jul 9, 2021
  3. maheshj01 commented on Jul 12, 2021

    @maheshj01
    Member

    Hi @jkevingutierrez,
    The issue is reproducible on the latest stable and the master channel. The textButton changes the cursor on hover while this doesn't work for CupertinoButton

    Code Sample
    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: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: MyHomePage(title: 'Flutter Demo Home Page'),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      MyHomePage({Key? key, required this.title}) : super(key: key);
    
      final String title;
    
      @override
      _MyHomePageState createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      int _counter = 0;
    
      void _incrementCounter() {
        setState(() {
          _counter++;
        });
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
            appBar: AppBar(
              title: Text(widget.title),
            ),
            body: MaterialApp(
              title: 'Flutter Demo',
              theme: ThemeData(
                primarySwatch: Colors.blue,
              ),
              home: Scaffold(
                appBar: AppBar(
                  title: const Text('Bug'),
                ),
                body: Center(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      CupertinoButton(
                        color: Colors.redAccent,
                        onPressed: () {
                          print('Cupertino');
                        },
                        child: const Text('Cupertino Button'),
                      ),
                      SizedBox(
                        height: 20,
                      ),
                      TextButton(
                        style: ButtonStyle(
                            backgroundColor: MaterialStateColor.resolveWith(
                                (states) => Colors.blueAccent)),
                        onPressed: () {
                          print('TextButton');
                        },
                        child: const Text(
                          'Click me',
                          style: TextStyle(color: Colors.white),
                        ),
                      ),
                      SizedBox(
                        height: 20,
                      ),
                      CupertinoButton(
                        onPressed: null,
                        color: Colors.purpleAccent,
                        child: const Text('Cupertino OnPressed null'),
                      ),
                      SizedBox(
                        height: 20,
                      ),
                      TextButton(
                        onPressed: null,
                        style: ButtonStyle(
                            backgroundColor: MaterialStateColor.resolveWith(
                                (states) => Colors.deepOrange)),
                        child: const Text('TextButton OnPressed null'),
                      ),
                    ],
                  ),
                ),
              ),
            ));
      }
    }
    
    
    Output
    Screen.Recording.2021-07-12.at.10.56.56.AM.mov
    flutter doctor -v
    [✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-arm, locale en-IN)
        • Flutter version 2.2.3 at /Users/mahesh/Documents/flutter
        • Framework revision f4abaa0735 (10 days ago), 2021-07-01 12:46:11 -0700
        • Engine revision 241c87ad80
        • Dart version 2.13.4
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-30, build-tools 30.0.3
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.4, Build version 12D4e
        • CocoaPods version 1.10.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.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.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.1.2)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 57.0.5
        • Dart plugin version 211.7233
    
    [✓] VS Code (version 1.58.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.24.0
    
    [✓] Connected device (2 available)
        • macOS (desktop) • macos  • darwin-arm64   • macOS 11.4 20F71 darwin-arm
        • Chrome (web)    • chrome • web-javascript • Google Chrome 91.0.4472.114
    
    • No issues found!
    
    [✓] Flutter (Channel master, 2.4.0-1.0.pre.149, on macOS 11.4 20F71 darwin-arm, locale en-IN)
        • Flutter version 2.4.0-1.0.pre.149 at /Users/mahesh/Documents/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision d71c0eb1d8 (3 days ago), 2021-07-09 06:01:04 -0400
        • Engine revision 024cc455fe
        • Dart version 2.14.0 (build 2.14.0-293.0.dev)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-30, build-tools 30.0.3
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.4, Build version 12D4e
        • CocoaPods version 1.10.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.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.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.1.2)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 57.0.5
        • Dart plugin version 211.7233
    
    [✓] VS Code (version 1.58.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.24.0
    
    [✓] Connected device (2 available)
        • macOS (desktop) • macos  • darwin-arm64   • macOS 11.4 20F71 darwin-arm
        • Chrome (web)    • chrome • web-javascript • Google Chrome 91.0.4472.114
    
    • No issues found!
    

    Thank you.

  4. added
    p: cupertino_uicupertino_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    platform-webWeb applications specifically
    a: mouseIssues related to using a mouse or mouse support
    and removed
    in triagePresently being triaged by the triage team
    on Jul 12, 2021
  5. Thaanu2001 commented on Jul 12, 2021

    @Thaanu2001

    @jkevingutierrez @maheshmnj I would like to work on this issue. Any procedure to start working?

  6. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    a: fidelityMatching the OEM platforms better
    and removed
    platform-webWeb applications specifically
    on Jul 15, 2021
  7. 1 remaining item

  8. maheshj01 commented on Aug 4, 2021

    @maheshj01
    Member

    @Thaanu2001 Please go through this https://github.com/flutter/flutter/blob/master/CONTRIBUTING.md
    specifically tree hygiene and issue hygiene

  9. self-assigned this
    on Dec 29, 2021
  10. changed the title [-]Most of Cupertino buttons in web don't change the cursor on hover[/-] [+]Cupertino widgets don't change mouse cursor when hover[/+] on Dec 29, 2021
  11. TahaTesser commented on Jan 19, 2022

    @TahaTesser
    Contributor

    Cupertino widgets, when hovered on Web, don't change the cursor. While it is expected behavior when running on native Desktop Apple Human Interface Guidelines - Mouse and Trackpad.

    Any web clickable component should update the cursor to clickable when an object can receive a click. As the author pointed it is unexpected behavior.

    Preview

    When cursor remains unchanged in the browser

    Screen.Recording.2022-01-19.at.16.02.59.mov

    When cursor updates to clickable in the browser

    Screen.Recording.2022-01-19.at.16.02.34.mov

    Add clickable cursor for Cupertino Widgets on the web.

  12. 0xNF commented on Feb 2, 2022

    @0xNF

    This is also a bit jarring when running on Windows Desktop. We can debate the appropriateness of using Apple widgets on a Microsoft platform, but clickable elements in the Windows world should change the cursor.

  13. TahaTesser commented on Feb 10, 2022

    @TahaTesser
    Contributor

    @0xNF
    According to Apple human design guidelines, cursor isn't suppose change on desktop, if you're using Cupertino non-mac platform on desktop this would still apply. If you looking for such feature, consider Material or fluent_ui for Windows fidelity.

  14. changed the title [-]Cupertino widgets don't change mouse cursor when hover[/-] [+]Cupertino widgets don't change mouse cursor when hover on web[/+] on Jun 22, 2022
  15. TahaTesser commented on Jun 22, 2022

    @TahaTesser
    Contributor

    Closing as fixed, all the PRs from #86174 (comment) are merged.

  16. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jun 22, 2022
  17. github-actions commented on Jul 6, 2022

    @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.

  18. locked as resolved and limited conversation to collaborators on Jul 6, 2022
  19. moved this to Done (PR merged) in Nevercodeon Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: fidelityMatching the OEM platforms bettera: mouseIssues related to using a mouse or mouse supportfound in release: 2.2Found to occur in 2.2found in release: 2.4Found to occur in 2.4frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cupertino_uicupertino_ui package in flutter/packagesplatform-webWeb applications specificallyr: 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