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

[super_drag_and_drop] Getting 'Invalid argument' error in macOS, but not on web #490

Open
LeoRc01 opened this issue Jan 10, 2025 · 0 comments

Comments

@LeoRc01
Copy link

LeoRc01 commented Jan 10, 2025

this is the code snippet:

final child = ....;

return DragItemWidget(
        dragItemProvider: (request) async {
          final item = DragItem(localData: const MyCustomModel(name: 'NAME'));

          return item;
        },
        allowedOperations: () => [DropOperation.move],
        child: DraggableWidget(child: child),
      );
     

and this is the model i'm trying to use;

class MyCustomModel {
  const MyCustomModel({
    required this.name,
  });

  final String name;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is MyCustomModel &&
          runtimeType == other.runtimeType &&
          name == other.name;

  @override
  int get hashCode => name.hashCode;
}

but when I try to Drag the item, on macOS I get this error, but on web it works just fine.

Error
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: Invalid argument: Instance of 'MyCustomModel'
#0      Serializer._writeValue (package:irondash_message_channel/src/codec.dart:161:7)
#1      Serializer._writeValue.<anonymous closure> (package:irondash_message_channel/src/codec.dart:158:9)
#2      _LinkedHashMapMixin.forEach (dart:_compact_hash:726:13)
#3      Serializer._writeValue (package:irondash_message_channel/src/codec.dart:156:13)
#4      Serializer._writeValue (package:irondash_message_channel/src/codec.dart:151:9)
#5      Serializer._writeValue.<anonymous closure> (package:irondash_message_channel/src/codec.dart:158:9)
#6      _LinkedHashMapMixin.forEach (dart:_compact_hash:726:13)
#7      Serializer._writeValue (package:irondash_message_channel/src/codec.dart:156:13)
#8      Serializer._writeValue.<anonymous closure> (package:irondash_message_channel/src/codec.dart:158:9)
#9      _LinkedHashMapMixin.forEach (dart:_compact_hash:726:13)
#10     Serializer._writeValue (package:irondash_message_channel/src/codec.dart:156:13)
#11     Serializer._writeValue (package:irondash_message_channel/src/codec.dart:151:9)
#12     Serializer._writeValue (package:irondash_message_channel/src/codec.dart:151:9)
#13     Serializer.serialize (package:irondash_message_channel/src/codec.dart:55:7)
#14     _NativeMessageChannelDelegate.postMessage (package:irondash_message_channel/src/native_message_channel_context.dart:42:46)
#15     NativeMessageChannelContext._postMessage (package:irondash_message_channel/src/native_message_channel_context.dart:101:16)
#16     NativeMessageChannelContext._sendMessage (package:irondash_message_channel/src/native_message_channel_context.dart:93:5)
#17     NativeMessageChannelContext.registerChannel.<anonymous closure> (package:irondash_message_channel/src/native_message_channel_context.dart:88:21)
#18     MessageChannel.sendMessage (package:irondash_message_channel/src/message_channel.dart:36:26)
#19     NativeMethodChannel.invokeMethod (package:irondash_message_channel/src/method_channel.dart:41:39)
#20     DragContextImpl.startDrag (package:super_native_extensions/src/native/drag.dart:241:24)
<asynchronous suspension>
#21     _DragDetector._maybeStartDragWithSession (package:super_drag_and_drop/src/drag_internal.dart:214:9)
<asynchronous suspension>
Doctor output
[✓] Flutter (Channel stable, 3.27.1, on macOS 15.0.1 24A348 darwin-arm64, locale
    it-IT)
    • Flutter version 3.27.1 on channel stable at
      /Users/leonardo/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 17025dd882 (4 weeks ago), 2024-12-17 03:23:09 +0900
    • Engine revision cb4b5fff73
    • Dart version 3.6.0
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/leonardo/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
    • All Android licenses accepted.

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

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

[✓] Android Studio (version 2024.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 21.0.3+-79915917-b509.11)

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

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   •
      macOS 15.0.1 24A348 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         •
      macOS 15.0.1 24A348 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript •
      Google Chrome 131.0.6778.265
    ! Error: Browsing on the local area network for iPhone di Leonardo. 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.

• No issues found!

Am I doing something wrong?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant