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

Modal bottom sheet drag doesn't animate on some devices #369

Closed
itsJoKr opened this issue Sep 1, 2023 · 4 comments
Closed

Modal bottom sheet drag doesn't animate on some devices #369

itsJoKr opened this issue Sep 1, 2023 · 4 comments

Comments

@itsJoKr
Copy link

itsJoKr commented Sep 1, 2023

I noticed that iOS-styled modal bottom sheet doesn't drag on some devices, such as Pixel 7a. It will animate screen behind correctly.

The same thing works on Android emulator, iOS simulator and iPhone devices.

Screen.Recording.2023-09-01.at.12.07.55.mov
@itsJoKr
Copy link
Author

itsJoKr commented Sep 1, 2023

I tracked the problem down to bottom_sheet.dart, in the build method there's the logic:

 mediaQuery.accessibleNavigation
                ? 1.0
                : widget.animationController.value);

I get the idea of disabling animation, BUT you cannot rely on accessibleNavigation to check if TalkBack is on.
In my case, I don't have any accessibility features turned on. You can read more about the issue here: flutter/flutter#128409

I think the best way is to remove the accessibleNavigation check making it always animate with widget.animationController.value.

@Meatysoda
Copy link

Same on Samsung phone. There is only animations on barrier color instead of sheet.
May my code help you.
MyBottomSheet is a copy of BarBottomSheet with different style.

Future<T?> showMyBottomSheet<T>({
  required BuildContext context,
  required WidgetBuilder builder,
...
}) {
//...
    if (showCompatibility) {
      myBuilder = (ctx) {
        return MyBottomSheet(child: builder(ctx));
      };
      myContainerWidget =
          (BuildContext ctx, Animation<double> animation, Widget child) {
        final tween = Tween<Offset>(
          begin: const Offset(0, 1),
          end: Offset.zero,
        ).chain(CurveTween(curve: Curves.easeOutCirc));
        return SlideTransition(
          position: tween.animate(animation),
          child: child,
        );
      };
    } else {
      myBuilder = builder;
      myContainerWidget = (_, __, Widget child) {
        return MyBottomSheet(
          child: child,
        );
      };
    }
    return showCustomModalBottomSheet(
      context: context,
      builder: myBuilder,
      containerWidget: myContainerWidget,...
    );
 
}

@orestesgaolin
Copy link
Collaborator

Wondering if this is still valid issue? I don't see the reference to mediaQuery.accessibleNavigation in the code anymore. Can you check @itsJoKr?

@itsJoKr
Copy link
Author

itsJoKr commented May 9, 2024

@orestesgaolin It works on Pixel 7A, so I guess it's fixed. Thanks for the info.

@itsJoKr itsJoKr closed this as completed May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants