jamesblasco / modal_bottom_sheet

Flutter | Create advanced modal bottom sheets. Material, Cupertino or your own style
https://pub.dev/packages/modal_bottom_sheet
MIT License
1.86k stars 470 forks source link

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

Closed itsJoKr closed 4 months ago

itsJoKr commented 1 year ago

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.

https://github.com/jamesblasco/modal_bottom_sheet/assets/11093480/c0191939-fe0e-4a31-9c17-952e581e2d3c

itsJoKr commented 1 year ago

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: https://github.com/flutter/flutter/issues/128409

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

Meatysoda commented 1 year ago

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 commented 4 months ago

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 commented 4 months ago

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