Hi I have several code on C# and I want call in on flutter. I add https://github.com/3F/DllExport to my C# project and create .dll
. I checked this .dll
in other C# project and in works.
My code on C#
{
[DllExport("scanResult", CallingConvention = CallingConvention.Cdecl)]
public static void scanResult()
{
Console.WriteLine("Hello, World!");
}
}
I add this .dll
to Flutter project:
1 in .yaml
add .dll
2 type
final DynamicLibrary nativePointerTestLib = DynamicLibrary.open("assets/Bluetooth.dll");
final void Function() testdllflutter =
nativePointerTestLib
.lookup<NativeFunction<Void Function()>>("scanResult")
.asFunction();
and I get error:
======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyUpEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyUpEvent#31063(physicalKey: PhysicalKeyboardKey#7002c(usbHidUsage: "0x0007002c", debugName: "Space"), logicalKey: LogicalKeyboardKey#00020(keyId: "0x00000020", keyLabel: " ", debugName: "Space"), character: null, timeStamp: 4:40:07.409359)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 441 pos 16: '_pressedKeys.containsKey(event.physicalKey)'
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.md
When the exception was thrown, this was the stack:
#2 HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:441:16)
#3 HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:452:6)
#4 HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:544:5)
#5 KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:867:35)
#6 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:77:49)
#7 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:76:47)
#8 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:380:35)
#9 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:377:46)
#10 _invoke2 (dart:ui/hooks.dart:187:13)
#11 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#12 _Channel._drainStep (dart:ui/channel_buffers.dart:224:31)
(elided 12 frames from class _AssertionError and dart:async)
============================================================
Can you hepl me. What I do wrong?