Flutter Engine
The Flutter Engine
Functions
fl_method_call.h File Reference
#include <glib-object.h>
#include <gmodule.h>
#include "fl_method_response.h"
#include "fl_value.h"

Go to the source code of this file.

Functions

G_BEGIN_DECLS G_MODULE_EXPORT const gchar * fl_method_call_get_name (FlMethodCall *method_call)
 
FlValuefl_method_call_get_args (FlMethodCall *method_call)
 
gboolean fl_method_call_respond (FlMethodCall *method_call, FlMethodResponse *response, GError **error)
 
gboolean fl_method_call_respond_success (FlMethodCall *method_call, FlValue *result, GError **error)
 

Function Documentation

◆ fl_method_call_get_args()

FlValue * fl_method_call_get_args ( FlMethodCall *  method_call)

fl_method_call_get_args: @method_call: an #FlMethodCall.

Gets the arguments passed to the method.

Returns: an FlValue.

Definition at line 72 of file fl_method_call.cc.

72 {
73 g_return_val_if_fail(FL_IS_METHOD_CALL(self), nullptr);
74 return self->args;
75}

◆ fl_method_call_get_name()

G_BEGIN_DECLS G_MODULE_EXPORT const gchar * fl_method_call_get_name ( FlMethodCall *  method_call)

FlMethodCall:

#FlMethodCall represents and incoming method call as returned by an #FlMethodChannel. fl_method_call_get_name: @method_call: an #FlMethodCall.

Gets the name of the method call.

Returns: a method name.

Definition at line 67 of file fl_method_call.cc.

67 {
68 g_return_val_if_fail(FL_IS_METHOD_CALL(self), nullptr);
69 return self->name;
70}

◆ fl_method_call_respond()

gboolean fl_method_call_respond ( FlMethodCall *  method_call,
FlMethodResponse *  response,
GError **  error 
)

fl_method_call_respond: @method_call: an #FlMethodCall. @response: an #FlMethodResponse. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Responds to a method call.

Returns: TRUE on success.

Definition at line 77 of file fl_method_call.cc.

79 {
80 g_return_val_if_fail(FL_IS_METHOD_CALL(self), FALSE);
81 g_return_val_if_fail(FL_IS_METHOD_RESPONSE(response), FALSE);
82
83 g_autoptr(GError) local_error = nullptr;
84 if (!fl_method_channel_respond(self->channel, self->response_handle, response,
85 &local_error)) {
86 // If the developer chose not to handle the error then log it so it's not
87 // missed.
88 if (error == nullptr) {
89 g_warning("Failed to send method call response: %s",
90 local_error->message);
91 }
92
93 g_propagate_error(error, local_error);
94 return FALSE;
95 }
96
97 return TRUE;
98}
gboolean fl_method_channel_respond(FlMethodChannel *self, FlBinaryMessengerResponseHandle *response_handle, FlMethodResponse *response, GError **error)
const uint8_t uint32_t uint32_t GError ** error
return FALSE

◆ fl_method_call_respond_success()

gboolean fl_method_call_respond_success ( FlMethodCall *  method_call,
FlValue result,
GError **  error 
)

fl_method_call_respond_success: @method_call: an #FlMethodCall.

Returns
: (allow-none): value to respond with, must match what the #FlMethodCodec supports. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Convenience method that responds to method call with #FlMethodSuccessResponse.

Returns: TRUE on success.

Definition at line 100 of file fl_method_call.cc.

102 {
103 g_return_val_if_fail(FL_IS_METHOD_CALL(self), FALSE);
104
105 g_autoptr(FlMethodResponse) response =
106 FL_METHOD_RESPONSE(fl_method_success_response_new(result));
107 return fl_method_channel_respond(self->channel, self->response_handle,
108 response, error);
109}
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)
GAsyncResult * result