ricnaaru / adv_camera

Advanced Camera for Flutter
BSD 3-Clause "New" or "Revised" License
54 stars 35 forks source link

Adv_Camera no longer respects its position in stack on android in Flutter 3.0 #62

Closed benneca closed 1 year ago

benneca commented 2 years ago

I have an issue with the adv_camera plugin within a stack maintaining its position in a stack with the release of flutter 3.0. This only seems to be an issue on android. below are two images, one with flutter 2.10.5 ( the adv_camera respects its position in the stack, at the bottom and the other elements are stacked and positioned on to) and the other with flutter 3.0(adv_camera does not respect its position in the stack and is also not aligned properly as you can see ii is slid up over the app bar. Has anyone else seen this issue and do you have a workaround? ea3185be-3a15-4a06-b4a5-5b06d7c13928 487ce36f-d853-4111-961e-55c83ecd691a

benneca commented 2 years ago

my guess is that this is due to the changes to the stack clippingbehavior and removal of the stack overlay parameter coupled with the clipRect and overflowbox being used in the camera itself. but as yet, I have not figured out quite how.

benneca commented 2 years ago

https://github.com/flutter/flutter/issues/103630

benneca commented 2 years ago

it's looking like the camera AndroidView will need to be changed to something like what's below for Flutter 3.0:

camera =
          PlatformViewLink(
            viewType: 'plugins.flutter.io/adv_camera',
            surfaceFactory: (
                BuildContext context,
                PlatformViewController controller,
                ) {
              return AndroidViewSurface(
                controller: controller as AndroidViewController,
                gestureRecognizers: gestureRecognizers ??
                    const <Factory<OneSequenceGestureRecognizer>>{},
                hitTestBehavior: PlatformViewHitTestBehavior.opaque,
              );
            },
            onCreatePlatformView: (PlatformViewCreationParams params) {

                          final AndroidViewController controller =

                             PlatformViewsService.initExpensiveAndroidView(
              id: params.id,
              viewType: 'plugins.flutter.io/adv_camera',
              layoutDirection: TextDirection.ltr,
              creationParams: creationParams,
              creationParamsCodec: const StandardMessageCodec(),
              onFocus: () => params.onFocusChanged(true),
              );
              controller.addOnPlatformViewCreatedListener(
              params.onPlatformViewCreated,
              );
              controller.addOnPlatformViewCreatedListener(
              onPlatformViewCreated,
              );
              return controller;
            },
          );

However, this currently only works on the master branch and not the stable branch. it looks like they are possibly cherry-picking a fix to make this work on stable

benneca commented 1 year ago

this is resolved for android in the latest version however, there has been an issue introduced with iOS where animatedContainers clip away. trying to work out more details. will post them as I learn more.

benneca commented 1 year ago

So the issue with iOS is that an animated bottom nav that previously would slide over the camera, no longer works. I replaced the animated bottom navigation elements with a showbottommodal and this resolved the issue satisfactorily for me, closing