Melo567 / ar_location_view

MIT License
23 stars 17 forks source link

ArLocationWidget Camera View is distorted (both vertical and horizontal) #6

Open romaklym opened 6 months ago

romaklym commented 6 months ago

ArLocationWidget Camera View is distorted and looks squashed on iPhone 14 Pro, and other models. Is there a way to fix this, to make it look natural? Thanks!

here is my body:

ArLocationWidget(
        annotations: annotations,
        showDebugInfoSensor: false,
        maxVisibleDistance: 100,
        showRadar: false,
        frame: Size.infinite,

        // radarPosition: RadarPosition.bottomCenter,
        // radarWidth: MediaQuery.of(context).size.width * 0.2,
        markerColor: AppColor.primaryColor,
        scaleWithDistance: true,
        annotationViewBuilder: (context, annotation) {
          if (annotation is Annotation && annotation.customWidget != null) {
            final customWidget = annotation.customWidget as MyCustomWidget;
            final distance = Geolocator.distanceBetween(
              widget.userLocation!.latitude,
              widget.userLocation!.longitude,
              annotation.position.latitude,
              annotation.position.longitude,
            );
            if (distance <= maxDistanceToShow) {
              return GestureDetector(
                onTap: () {
                  showGeneralDialog(
                    context: context,
                    barrierDismissible: true,
                    barrierLabel: MaterialLocalizations.of(context)
                        .modalBarrierDismissLabel,
                    transitionDuration: const Duration(milliseconds: 300),
                    pageBuilder: (BuildContext buildContext,
                        Animation animation, Animation secondaryAnimation) {
                      return Center(
                        child: AlertDialog(
                          backgroundColor: AppColor.primaryColor,
                          title: Text(
                            customWidget.placeName,
                            style: TextStyle(
                              color: AppColor.darkText,
                              fontWeight: FontWeight.bold,
                              fontFamily: 'KeaniaOne',
                              fontSize: 20.0,
                            ),
                            textAlign: TextAlign.center,
                          ),
                          content: Text(
                            'This is ${customWidget.placeName}. Distance: ${distance.toStringAsFixed(2)} meters',
                            style: TextStyle(
                              color: AppColor.darkText,
                              fontWeight: FontWeight.bold,
                              fontFamily: 'Inter',
                              fontSize: 16.0,
                            ),
                            textAlign: TextAlign.center,
                          ),
                          actions: <Widget>[
                            GestureDetector(
                              onTap: () {
                                if (mounted) {
                                  Navigator.of(buildContext).pop();
                                }
                              },
                              child: Container(
                                decoration: BoxDecoration(
                                  gradient: const LinearGradient(colors: [
                                    Color(0xFF56ab2f),
                                    Color(0xFFa8e063)
                                  ]),
                                  borderRadius: BorderRadius.circular(12),
                                  border: Border(
                                    right: BorderSide(
                                        color: Colors.green.shade700,
                                        width:
                                            5), // Example border on the right
                                    bottom: BorderSide(
                                        color: Colors.green.shade700,
                                        width:
                                            5), // Example border on the bottom
                                    left: BorderSide.none, // No border
                                    top: BorderSide.none, // No border
                                  ),
                                ),
                                child: Padding(
                                  padding: const EdgeInsets.all(8.0),
                                  child: Text(
                                    'OK',
                                    style: TextStyle(
                                      color: AppColor.transparentWhiteColor,
                                      fontWeight: FontWeight.bold,
                                      fontFamily: 'BalsamiqSans',
                                      fontSize: 16,
                                    ),
                                  ),
                                ),
                              ),
                            ),
                          ],
                        ),
                      );
                    },
                  );
                },
                // child: AnnotationView(
                //   imageAssetPath: customWidget.imageAssetPath,
                //   distance: distance,
                // ),
                child: Image.asset(
                  customWidget.imageAssetPath,
                  height: imageHeight,
                ),
              );
            }
          }
          return const SizedBox.shrink();
        },
        onLocationChange: (Position position) {
          Future.delayed(const Duration(seconds: 5), () {
            updateAnnotationsOnLocationChange(position);

            setState(() {});
          });
        },
      ),
Rejvenn commented 3 months ago

did anyone found a solution for this bug ?

staminna commented 1 month ago

I also have a distortion of the image in the latest Android version for my Samsung S21.