Skip to content

Button splash radius does not update when pressed #121626

Closed

Description

@mikuhl-dev

Steps to Reproduce

  1. Update buttons border radius when pressed.

Expected results:

Buttons splash border radius updates when pressed.

image

Actual results:

Buttons splash border radius does not update when pressed.

image

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark(
        useMaterial3: true,
      ),
      home: Scaffold(
        body: Center(
          child: FilledButton(
            style: ButtonStyle(
              fixedSize: MaterialStateProperty.all(const Size(80, 80)),
              shape: MaterialStateProperty.resolveWith(
                (states) => RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(
                    states.contains(MaterialState.pressed) ? 20 : 50,
                  ),
                ),
              ),
            ),
            child: const Text('Button'),
            onPressed: () {},
          ),
        ),
      ),
    );
  }
}
Logs
[√] Flutter (Channel stable, 3.7.3, on Microsoft Windows [Version 10.0.22623.1325], locale en-US)
    • Flutter version 3.7.3 on channel stable at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9944297138 (3 weeks ago), 2023-02-08 15:46:04 -0800
    • Engine revision 248290d6d5
    • Dart version 2.19.2
    • DevTools version 2.20.1

This circular button that changes border radius when pressed is found in many of googles apps.

image

Activity

  1. changed the title [-]Buttons splash border radius does not update when pressed[/-] [+]Buttons splash radius does not update when pressed[/+] on Mar 1, 2023
  2. changed the title [-]Buttons splash radius does not update when pressed[/-] [+]Button splash radius does not update when pressed[/+] on Mar 1, 2023
  3. danagbemava-nc commented on Mar 1, 2023

    @danagbemava-nc
    Member

    I can reproduce the issue using the code sample provided above.

    It seems like when the shape changes before the button is pressed, the splash is properly updated but when the button is actively pressed, the shape doesn't properly update. I tested this by changing the state in the sample above to check for hovered instead of pressed.

    recordings
    state: hovered state: pressed
    Screen.Recording.2023-03-01.at.07.43.57.mov
    Screen.Recording.2023-03-01.at.07.44.16.mov

    Looking at the timer in the clock app where this is likely to be easily visible, it looks like the shape changes before the splash is drawn but in the flutter app, the splash is drawn at almost the exact same time the shape is being changed. The pin input screen on the pixel also has this effect but the animation is faster on that side.

    timer app recording
    telegram-cloud-document-4-6051046017355222600.mp4

    Labeling for further investigation

    flutter doctor -v
    [✓] Flutter (Channel stable, 3.7.5, on macOS 13.2.1 22D68 darwin-arm64, locale en-GB)
        • Flutter version 3.7.5 on channel stable at /Users/nexus/dev/sdks/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision c07f788888 (6 days ago), 2023-02-22 17:52:33 -0600
        • Engine revision 0f359063c4
        • Dart version 2.19.2
        • DevTools version 2.20.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.2)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14C18
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [!] Android Studio (version 2022.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
        ✗ Unable to find bundled Java version.
        • Try updating or re-installing Android Studio.
    
    [!] Android Studio (version 2022.1)
        • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/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
        ✗ Unable to find bundled Java version.
        • Try updating or re-installing Android Studio.
    
    [✓] IntelliJ IDEA Community Edition (version 2022.3.2)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • 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
    
    [✓] VS Code (version 1.75.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.58.0
    
    [✓] Connected device (2 available)
        • macOS (desktop) • macos  • darwin-arm64   • macOS 13.2.1 22D68 darwin-arm64
        • Chrome (web)    • chrome • web-javascript • Google Chrome 110.0.5481.177
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 2 categories.
    
    [!] Flutter (Channel master, 3.8.0-18.0.pre.28, on macOS 13.2.1 22D68 darwin-arm64, locale en-GB)
        • Flutter version 3.8.0-18.0.pre.28 on channel master at /Users/nexus/dev/sdks/flutters
        ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 25712d95d3 (4 hours ago), 2023-02-28 19:31:23 -0800
        • Engine revision 46ee3209b9
        • Dart version 3.0.0 (build 3.0.0-277.0.dev)
        • DevTools version 2.22.1
        • 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)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0
        • Java binary at: /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.2)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14C18
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.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.15+0-b2043.56-8887301)
    
    [✓] Android Studio (version 2022.1)
        • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/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.15+0-b2043.56-8887301)
    
    [✓] IntelliJ IDEA Community Edition (version 2022.3.2)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • 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
    
    [✓] VS Code (version 1.75.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.58.0
    
    [✓] Connected device (2 available)
        • macOS (desktop) • macos  • darwin-arm64   • macOS 13.2.1 22D68 darwin-arm64
        • Chrome (web)    • chrome • web-javascript • Google Chrome 110.0.5481.177
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
    
  4. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Mar 1, 2023
  5. bleroux commented on Mar 1, 2023

    @bleroux
    Contributor

    FYI, there was a similar issue about button shape not being updated when hovered (#114301).

    I will try to figure out a fix for this one.
    InkWell draws highlights for each state and also a splash when pressed. The objects describing what should be drawn (color, shape, etc) have to be replaced when one of those properties is updated.

  6. self-assigned this
    on Mar 1, 2023
  7. mikuhl-dev commented on Mar 5, 2023

    @mikuhl-dev
    Author

    Looked into what this type of button is called, it is called a MotionButton.

  8. moved this from To do to In progress in Nevercodeon Mar 25, 2023
  9. moved this from In progress to Done (PR merged) in Nevercodeon Mar 27, 2023
  10. added
    r: fixedIssue is closed as already fixed in a newer version
    on Mar 27, 2023
  11. github-actions commented on Apr 10, 2023

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

  12. locked as resolved and limited conversation to collaborators on Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

found in release: 3.7Found to occur in 3.7found in release: 3.8Found to occur in 3.8frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: 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