deakjahn / flutter_dropzone

A drag-and-drop Flutter plugin (Web). Only web and only from outside into Flutter.
https://pub.dev/packages/flutter_dropzone
85 stars 36 forks source link

Resizing not working properly in Firefox #82

Open FlorentineDraegerProtofy opened 3 months ago

FlorentineDraegerProtofy commented 3 months ago

We're using dropzone in our Flutter project and the resizing of our widget is not working properly in firefox. When removing the dropzoneview, resizing starts working. It works fine in chrome

  Widget build(BuildContext context) {
    final isHighlighted = ref.watch(importNotifierProvider).isImportBoxHighlighted;

    void handleDropFile(dynamic ev) async {
      final file = await controller.getFileData(ev);
      final droppedFile = await convertDroppedFile(file);
      final rootCompany = ref.read(rootCompanyProvider)!;
      await ref.read(importNotifierProvider.notifier).startImport(
            rootCompany.id,
            droppedFile,
          );
      ref.read(importNotifierProvider.notifier).startWatchingImportStatus();
    }

    return Stack(
      children: [
        Container(
          color: isHighlighted ? theme.colors.background.success : Colors.transparent,
          child: DropzoneView(
            operation: DragOperation.copy,
            cursor: CursorType.grab,
            onCreated: (DropzoneViewController ctrl) {
              controller = ctrl;
            },
            onDrop: handleDropFile,
            onHover: () {
              ref.read(importNotifierProvider.notifier).setImportBoxisHighlighted(true);
            },
            onLeave: () {
              ref.read(importNotifierProvider.notifier).setImportBoxisHighlighted(false);
            },
          ),
        ),
        GestureDetector(
          onTap: widget.onTap,
          child: MouseRegion(
            cursor: SystemMouseCursors.click,
            child: DottedBorder(
              dashPattern: const [8, 4],
              borderType: BorderType.RRect,
              color: Colors.black,
              strokeWidth: 1,
              radius: Radius.circular(theme.spacing.factor(1.5)),
              child: Padding(
                padding: const EdgeInsets.all(24.0),
                child: Column(
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Icon(
                        color: Colors.black,
                        Icons.file_upload_outlined,
                        size: theme.spacing.factor(4),
                      ),
                      const VerticalSpacer(2),
                      Center(
                        child: RichText(
                          textAlign: TextAlign.center,
                          text: TextSpan(
                            children: <TextSpan>[
                              TextSpan(
                                text:
                                    LocaleKeys.maintenance_emptyState_import_uploadButtonFirst.tr(),
                                style: theme.textTheme.bodyMedium!.copyWith(
                                  color: theme.colors.text.primary,
                                  fontWeight: FontWeight.w500,
                                ),
                              ),
                              const TextSpan(text: ' '),
                              TextSpan(
                                text: LocaleKeys.uploadButtonSecond
                                    .tr(),
                                style: theme.textTheme.bodyMedium!.copyWith(
                                  color: theme.colors.text.secondary,
                                ),
                              ),
                            ],
                          ),
                        ),
                      )
                    ]),
              ),
            ),
          ),
        ),
      ],
    );
  }
}

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.19.0, on macOS 14.3.1 23D60 darwin-arm64, locale en-DE) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) [✓] Xcode - develop for iOS and macOS (Xcode 15.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.3) [✓] Android Studio (version 2022.3) [✓] IntelliJ IDEA Ultimate Edition (version 2022.2.3) [✓] VS Code (version 1.88.1) [✓] Connected device (3 available) ! Error: Browsing on the local area network for Florentine’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac. The device must be opted into Developer Mode to connect wirelessly. (code -27) [✓] Network resources

• No issues found!

deakjahn commented 3 months ago

There was a rather recent problem in Flutter involving Firefox, although, as far as I know, not specifically resizing, see https://github.com/deakjahn/flutter_dropzone/issues/77. Could it be related by any chance? At any rate, I see that you're quite a few versions behind the current Flutter — 3.19.0 rather than 3.19.6 —, so you might want to try this first.