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

[desktop_drop] after a drag and drop the app doesn't rebuild itself until it is selected on macOS #382

Open
stephane-archer opened this issue Dec 19, 2024 · 3 comments
Labels
desktop_drop plugin desktop_drop platform-macos question Further information is requested

Comments

@stephane-archer
Copy link

Screen.Recording.2024-12-19.at.02.19.26.mov

after a drag and drop the app doesn't rebuild itself until it is selected on macOS

Expected results

I expect the app to react to the drag and drop and rebuild itself to give immediate feedback to the user.

Actual results

the app doesn't rebuild itself after a drag and drop on macOS

[✓] Flutter (Channel stable, 3.24.5, on macOS 15.1 24B83 darwin-x64, locale en-GB)
    • Flutter version 3.24.5 on channel stable at /Users/fractale/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (5 weeks ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/fractale/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/macos-android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.96.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 15.1 24B83 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 131.0.6778.141
    ! Error: Browsing on the local area network for Melimelo. 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
    • All expected network resources are available.

! Doctor found issues in 1 category.

I use a DropTarget from desktop_drop-0.5.0

@boyan01
Copy link
Contributor

boyan01 commented Dec 19, 2024

I tried it with the example and it worked as expected. The video is as follows

2024-12-19.23.08.40.mov

Could you provide some reproducible code ,so that we can find out why the problem occurs?

@boyan01 boyan01 added question Further information is requested desktop_drop plugin desktop_drop platform-macos labels Dec 19, 2024
@stephane-archer
Copy link
Author

@boyan01 I can't explain what is happening. this doesn't happen every time.
If I start playing with another window it doesn't work but if I only play with the finder and the app it works as expected.
Can you observe the same behavior on your side?

output.mov

@stephane-archer
Copy link
Author

stephane-archer commented Dec 20, 2024

Here is the code for reproducing the issue. just drop folder to the app

import 'dart:async';

import 'package:desktop_drop/desktop_drop.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

void main() {
  runApp(const ProviderScope(child: MyApp()));
}

final favoriteFoldersProvider = StateProvider<int>(
  (ref) => 0,
);

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends ConsumerWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final favoriteFolders = ref.watch(favoriteFoldersProvider);
    return Scaffold(
      appBar: AppBar(),
      body: DropTarget(
        onDragDone: (dropDoneDetails) async {
          await _processDroppedFiles(
            dropDoneDetails,
            ref,
          );
        },
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(favoriteFolders.toString()),
            ],
          ),
        ),
      ),
    );
  }

  static Future<void> _processDroppedFiles(
    DropDoneDetails dropDoneDetails,
    WidgetRef ref,
  ) async {
    var files = dropDoneDetails.files;
    final filePaths = files.map((e) {
      return e.path;
    });
    if (filePaths.isEmpty) {
      return;
    }
    var favoriteFolders = ref.read(favoriteFoldersProvider.notifier);
    for (var i = 0; i < filePaths.length; i++) {
      favoriteFolders.update((state) {
        return state + 1;
      });
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop_drop plugin desktop_drop platform-macos question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants