private void HandleMethodCall(MethodCall call, MethodChannel.IResult result)
        {
            // Return an error if Flutter is invoking method calls through method channel
            // when bridge is configured for WebSocket communication
            if (Mode == FlutnetBridgeMode.WebSocket)
            {
                result.NotImplemented();
                return;
            }

            // Extract target method information from MethodCall.Method
            FlutnetMethodInfo methodInfo;
            Object            dartReturnValue;

            try
            {
                methodInfo      = JsonConvert.DeserializeObject <FlutnetMethodInfo>(call.Method, FlutterInterop.JsonSerializerSettings);
                dartReturnValue = FlutterInterop.ToMethodChannelResult(0);
            }
            catch (Exception ex)
            {
                result.Error(FlutnetErrorCode.OperationNotImplemented.ToString(), ex.Message, null);
                return;
            }

            // Send an empty - successful - response to immediately free Flutter thread
            result.Success(dartReturnValue);
            Task.Run(() => { BackgroundHandleMethodCall(methodInfo, call); });
        }
        private void HandleMethodCallTest(MethodCall call, MethodChannel.IResult result)
        {
            if (call.Method == "FlutnetBridgeMode")
            {
                switch (Mode)
                {
                case FlutnetBridgeMode.PlatformChannel:
                    result.Success("PlatformChannel");
                    break;

                case FlutnetBridgeMode.WebSocket:
                    result.Success("WebSocket");
                    break;
                }
            }
            else
            {
                // Right now this handler is called just once at application startup
                // when Flutter module tries to detect if it's running
                // embedded into a native Xamarin app or as a standalone app
                result.Success("ok");
            }
        }
            // callback from Flutter with a method...
            public async void OnMethodCall(MethodCall methodCall, MethodChannel.IResult result)
            {
                try
                {
                    Android.Util.Log.WriteLine(Android.Util.LogPriority.Info, "Vistian.Flutter.Remoting.Droid.Example", $"Message received {methodCall.Method} for {_handler.GetType().Name}");
                    Stopwatch stopWatch = new Stopwatch();

                    stopWatch.Start();

                    // decode the method details from the method call
                    var arg = methodCall.Argument(DetailsArgumentName);


                    var t0 = stopWatch.ElapsedTicks;
                    var ns = arg.ToString();


                    var t1 = stopWatch.ElapsedTicks;
                    // invoke the registered handler for this method and the message details
                    var messagingResult = await _handler.Execute(methodCall.Method, ns).ConfigureAwait(false);

                    var t2 = stopWatch.ElapsedTicks;
                    // serialize up the message result,
                    var jsonMessagingResult = JsonConvert.SerializeObject(messagingResult);
                    var t3 = stopWatch.ElapsedTicks;
                    stopWatch.Stop();

                    Android.Util.Log.WriteLine(Android.Util.LogPriority.Info, "Vistian.Flutter.Remoting.Droid.Example", $"Messaging Handling took {stopWatch.ElapsedMilliseconds} {t0} {t1} {t2} {t3} freq: {Stopwatch.Frequency}");
                    // and send it back
                    result.Success(jsonMessagingResult);
                }
                catch (Exception exception)
                {
                    // report the error back to flutter
                    result.Error(exception.GetType().Name, exception.Message, exception.Source);
                }
            }
 /// <summary>
 /// <para>
 /// Handles the specified method call received from Flutter.
 /// </para>
 /// <para>
 /// Handler implementations must submit a result for all incoming calls, by making a single call
 /// on the given <see cref="MethodChannel.IResult"/> callback.
 /// Failure to do so will result in lingering Flutter result handlers.
 /// The result may be submitted asynchronously.
 /// Calls to unknown or unimplemented methods should be handled using <see cref="MethodChannel.IResult.NotImplemented"/>.
 /// </para>
 /// <para>
 /// Any uncaught exception thrown by this method will be caught by the channel implementation and logged,
 /// and an error result will be sent back to Flutter.
 /// </para>
 /// <para>
 /// The handler is called on the platform thread (Android main thread).
 /// For more details see <see href="https://github.com/flutter/engine/wiki/Threading-in-the-Flutter-Engine">Threading in the Flutter Engine</see>.
 /// </para>
 /// </summary>
 /// <param name="call">A <see cref="MethodCall"/>.</param>
 /// <param name="result">A <see cref="MethodChannel.IResult"/> used for submitting the result of the call.</param>
 public void OnMethodCall(MethodCall call, MethodChannel.IResult result)
 {
     _onMethodCall?.Invoke(call, result);
 }