Flutter Engine
flutter::PlatformConfiguration Class Referencefinal

A class for holding and distributing platform-level information to and from the Dart code in Flutter's framework. More...

#include <platform_configuration.h>

Public Member Functions

 PlatformConfiguration (PlatformConfigurationClient *client)
 Creates a new PlatformConfiguration, typically created by the RuntimeController. More...
 
 PlatformConfiguration (const PlatformConfiguration &)=delete
 
PlatformConfigurationoperator= (const PlatformConfiguration &)=delete
 
 ~PlatformConfiguration ()
 
PlatformConfigurationClientclient () const
 Access to the platform configuration client (which typically is implemented by the RuntimeController). More...
 
void DidCreateIsolate ()
 Called by the RuntimeController once it has created the root isolate, so that the PlatformController can get a handle to the 'dart:ui' library. More...
 
void UpdateLocales (const std::vector< std::string > &locales)
 Update the specified locale data in the framework. More...
 
void UpdateUserSettingsData (const std::string &data)
 Update the user settings data in the framework. More...
 
void UpdateLifecycleState (const std::string &data)
 Updates the lifecycle state data in the framework. More...
 
void UpdateSemanticsEnabled (bool enabled)
 Notifies the PlatformConfiguration that the embedder has expressed an opinion about whether the accessibility tree should be generated or not. This call originates in the platform view and is forwarded to the PlatformConfiguration here by the engine. More...
 
void UpdateAccessibilityFeatures (int32_t flags)
 Forward the preference of accessibility features that must be enabled in the semantics tree to the framwork. More...
 
void DispatchPlatformMessage (std::unique_ptr< PlatformMessage > message)
 Notifies the PlatformConfiguration that the client has sent it a message. This call originates in the platform view and has been forwarded through the engine to here. More...
 
void DispatchSemanticsAction (int32_t id, SemanticsAction action, fml::MallocMapping args)
 Notifies the framework that the embedder encountered an accessibility related action on the specified node. This call originates on the platform view and has been forwarded to the platform configuration here by the engine. More...
 
uint64_t RegisterKeyDataResponse (KeyDataResponse callback)
 Registers a callback to be invoked when the framework has decided whether to handle an event. This callback originates in the platform view and has been forwarded through the engine to here. More...
 
void BeginFrame (fml::TimePoint frame_time, uint64_t frame_number)
 Notifies the framework that it is time to begin working on a new frame previously scheduled via a call to PlatformConfigurationClient::ScheduleFrame. This call originates in the animator. More...
 
void ReportTimings (std::vector< int64_t > timings)
 Dart code cannot fully measure the time it takes for a specific frame to be rendered. This is because Dart code only runs on the UI task runner. That is only a small part of the overall frame workload. The raster task runner frame workload is executed on a thread where Dart code cannot run (and hence instrument). Besides, due to the pipelined nature of rendering in Flutter, there may be multiple frame workloads being processed at any given time. However, for non-Timeline based profiling, it is useful for trace collection and processing to happen in Dart. To do this, the raster task runner frame workloads need to be instrumented separately. After a set number of these profiles have been gathered, they need to be reported back to Dart code. The engine reports this extra instrumentation information back to the framework by invoking this method at predefined intervals. More...
 
Windowget_window (int window_id)
 Retrieves the Window with the given ID managed by the PlatformConfiguration. More...
 
void CompletePlatformMessageResponse (int response_id, std::vector< uint8_t > data)
 Responds to a previous platform message to the engine from the framework. More...
 
void CompletePlatformMessageEmptyResponse (int response_id)
 Responds to a previous platform message to the engine from the framework with an empty response. More...
 
void CompleteKeyDataResponse (uint64_t response_id, bool handled)
 Responds to a previously registered key data message from the framework to the engine. More...
 

Static Public Member Functions

static void RegisterNatives (tonic::DartLibraryNatives *natives)
 Registers the native handlers for Dart functions that this class handles. More...
 

Detailed Description

A class for holding and distributing platform-level information to and from the Dart code in Flutter's framework.

It handles communication between the engine and the framework, and owns the main window.

It communicates with the RuntimeController through the use of a PlatformConfigurationClient interface, which the RuntimeController defines.

Definition at line 217 of file platform_configuration.h.

Constructor & Destructor Documentation

◆ PlatformConfiguration() [1/2]

flutter::PlatformConfiguration::PlatformConfiguration ( PlatformConfigurationClient client)
explicit

Creates a new PlatformConfiguration, typically created by the RuntimeController.

Parameters
[in]clientThe PlatformConfigurationClient to be injected into the PlatformConfiguration. This client is used to forward requests to the RuntimeController.

Definition at line 201 of file platform_configuration.cc.

203  : client_(client) {}
PlatformConfigurationClient * client() const
Access to the platform configuration client (which typically is implemented by the RuntimeController)...

◆ PlatformConfiguration() [2/2]

flutter::PlatformConfiguration::PlatformConfiguration ( const PlatformConfiguration )
delete

◆ ~PlatformConfiguration()

flutter::PlatformConfiguration::~PlatformConfiguration ( )

Definition at line 205 of file platform_configuration.cc.

205 {}

Member Function Documentation

◆ BeginFrame()

void flutter::PlatformConfiguration::BeginFrame ( fml::TimePoint  frame_time,
uint64_t  frame_number 
)

Notifies the framework that it is time to begin working on a new frame previously scheduled via a call to PlatformConfigurationClient::ScheduleFrame. This call originates in the animator.

The frame time given as the argument indicates the point at which the current frame interval began. It is very slightly (because of scheduling overhead) in the past. If a new layer tree is not produced and given to the raster task runner within one frame interval from this point, the Flutter application will jank.

This method calls the ::_beginFrame method in hooks.dart.

Parameters
[in]frame_timeThe point at which the current frame interval began. May be used by animation interpolators, physics simulations, etc..
[in]frame_numberThe frame number recorded by the animator. Used by the framework to associate frame specific debug information with frame timings and timeline events.

Definition at line 370 of file platform_configuration.cc.

References flutter::UIDartState::Current(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), tonic::DartInvokeVoid(), flutter::UIDartState::FlushMicrotasksNow(), tonic::DartPersistentValue::Get(), and tonic::LogIfError().

371  {
372  std::shared_ptr<tonic::DartState> dart_state =
373  begin_frame_.dart_state().lock();
374  if (!dart_state) {
375  return;
376  }
377  tonic::DartState::Scope scope(dart_state);
378 
379  int64_t microseconds = (frameTime - fml::TimePoint()).ToMicroseconds();
380 
382  tonic::DartInvoke(begin_frame_.Get(), {
383  Dart_NewInteger(microseconds),
384  Dart_NewInteger(frame_number),
385  }));
386 
388 
390 }
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:20
const std::weak_ptr< DartState > & dart_state() const
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15
Dart_Handle DartInvokeVoid(Dart_Handle closure)
Definition: dart_invoke.cc:29
static UIDartState * Current()

◆ client()

PlatformConfigurationClient* flutter::PlatformConfiguration::client ( ) const
inline

Access to the platform configuration client (which typically is implemented by the RuntimeController).

Returns
Returns the client used to construct this PlatformConfiguration.

Definition at line 242 of file platform_configuration.h.

References action, args, callback, flutter::DispatchPlatformMessage(), flutter::DispatchSemanticsAction(), and flutter::flags.

Referenced by flutter::DartIsolate::AddIsolateShutdownCallback(), flutter::ComputePlatformResolvedLocale(), and flutter::decodeStrut().

242 { return client_; }

◆ CompleteKeyDataResponse()

void flutter::PlatformConfiguration::CompleteKeyDataResponse ( uint64_t  response_id,
bool  handled 
)

Responds to a previously registered key data message from the framework to the engine.

For each response_id, this method should be called exactly once. Responding to a response_id that has not been registered or has been invoked will lead to a fatal error.

Parameters
[in]response_idThe unique id that identifies the original platform message to respond to, created by RegisterKeyDataResponse.
[in]handledWhether the key data is handled.

Definition at line 447 of file platform_configuration.cc.

References callback, flutter::UIDartState::Current(), FML_DCHECK, flutter::TaskRunners::GetPlatformTaskRunner(), flutter::UIDartState::GetTaskRunners(), and fml::TaskRunner::PostTask().

448  {
449  if (response_id == 0) {
450  return;
451  }
452  auto it = pending_key_responses_.find(response_id);
453  FML_DCHECK(it != pending_key_responses_.end());
454  if (it == pending_key_responses_.end()) {
455  return;
456  }
457  KeyDataResponse callback = std::move(it->second);
458  pending_key_responses_.erase(it);
459  // The key result callback must be called on the platform thread. This is
460  // mainly because iOS needs to block the platform message loop with a nested
461  // loop to respond to key events synchronously, and if the callback is called
462  // from another thread, it won't stop the nested message loop, causing a
463  // deadlock.
465  [handled, callback]() { callback(handled); });
466 }
#define FML_DCHECK(condition)
Definition: logging.h:86
fml::RefPtr< fml::TaskRunner > GetPlatformTaskRunner() const
Definition: task_runners.cc:30
FlKeyEvent FlKeyResponderAsyncCallback callback
std::function< void(bool)> KeyDataResponse
const TaskRunners & GetTaskRunners() const
virtual void PostTask(const fml::closure &task) override
Definition: task_runner.cc:24
static UIDartState * Current()

◆ CompletePlatformMessageEmptyResponse()

void flutter::PlatformConfiguration::CompletePlatformMessageEmptyResponse ( int  response_id)

Responds to a previous platform message to the engine from the framework with an empty response.

Parameters
[in]response_idThe unique id that identifies the original platform message to respond to.

Definition at line 418 of file platform_configuration.cc.

References flutter::PlatformMessageResponse::CompleteEmpty().

419  {
420  if (!response_id) {
421  return;
422  }
423  auto it = pending_responses_.find(response_id);
424  if (it == pending_responses_.end()) {
425  return;
426  }
427  auto response = std::move(it->second);
428  pending_responses_.erase(it);
429  response->CompleteEmpty();
430 }

◆ CompletePlatformMessageResponse()

void flutter::PlatformConfiguration::CompletePlatformMessageResponse ( int  response_id,
std::vector< uint8_t >  data 
)

Responds to a previous platform message to the engine from the framework.

Parameters
[in]response_idThe unique id that identifies the original platform message to respond to.
[in]dataThe data to send back in the response.

Definition at line 432 of file platform_configuration.cc.

References flutter::PlatformMessageResponse::Complete().

434  {
435  if (!response_id) {
436  return;
437  }
438  auto it = pending_responses_.find(response_id);
439  if (it == pending_responses_.end()) {
440  return;
441  }
442  auto response = std::move(it->second);
443  pending_responses_.erase(it);
444  response->Complete(std::make_unique<fml::DataMapping>(std::move(data)));
445 }

◆ DidCreateIsolate()

void flutter::PlatformConfiguration::DidCreateIsolate ( )

Called by the RuntimeController once it has created the root isolate, so that the PlatformController can get a handle to the 'dart:ui' library.

It uses the handle to call the hooks in hooks.dart.

Definition at line 207 of file platform_configuration.cc.

References tonic::DartState::Current(), tonic::DartPersistentValue::Set(), and tonic::ToDart().

207  {
208  Dart_Handle library = Dart_LookupLibrary(tonic::ToDart("dart:ui"));
209  update_locales_.Set(tonic::DartState::Current(),
210  Dart_GetField(library, tonic::ToDart("_updateLocales")));
211  update_user_settings_data_.Set(
213  Dart_GetField(library, tonic::ToDart("_updateUserSettingsData")));
214  update_lifecycle_state_.Set(
216  Dart_GetField(library, tonic::ToDart("_updateLifecycleState")));
217  update_semantics_enabled_.Set(
219  Dart_GetField(library, tonic::ToDart("_updateSemanticsEnabled")));
220  update_accessibility_features_.Set(
222  Dart_GetField(library, tonic::ToDart("_updateAccessibilityFeatures")));
223  dispatch_platform_message_.Set(
225  Dart_GetField(library, tonic::ToDart("_dispatchPlatformMessage")));
226  dispatch_semantics_action_.Set(
228  Dart_GetField(library, tonic::ToDart("_dispatchSemanticsAction")));
229  begin_frame_.Set(tonic::DartState::Current(),
230  Dart_GetField(library, tonic::ToDart("_beginFrame")));
231  draw_frame_.Set(tonic::DartState::Current(),
232  Dart_GetField(library, tonic::ToDart("_drawFrame")));
233  report_timings_.Set(tonic::DartState::Current(),
234  Dart_GetField(library, tonic::ToDart("_reportTimings")));
235  windows_.insert(
236  std::make_pair(0, std::unique_ptr<Window>(new Window{
237  0, ViewportMetrics{1.0, 0.0, 0.0, -1}})));
238 }
void Set(DartState *dart_state, Dart_Handle value)
static DartState * Current()
Definition: dart_state.cc:56
Dart_Handle ToDart(const T &object)

◆ DispatchPlatformMessage()

void flutter::PlatformConfiguration::DispatchPlatformMessage ( std::unique_ptr< PlatformMessage message)

Notifies the PlatformConfiguration that the client has sent it a message. This call originates in the platform view and has been forwarded through the engine to here.

Parameters
[in]messageThe message sent from the embedder to the Dart application.

Definition at line 308 of file platform_configuration.cc.

References tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), FML_DLOG, tonic::DartPersistentValue::Get(), tonic::LogIfError(), and tonic::ToDart().

309  {
310  std::shared_ptr<tonic::DartState> dart_state =
311  dispatch_platform_message_.dart_state().lock();
312  if (!dart_state) {
313  FML_DLOG(WARNING)
314  << "Dropping platform message for lack of DartState on channel: "
315  << message->channel();
316  return;
317  }
318  tonic::DartState::Scope scope(dart_state);
319  Dart_Handle data_handle =
320  (message->hasData()) ? ToByteData(message->data()) : Dart_Null();
321  if (Dart_IsError(data_handle)) {
322  FML_DLOG(WARNING)
323  << "Dropping platform message because of a Dart error on channel: "
324  << message->channel();
325  return;
326  }
327 
328  int response_id = 0;
329  if (auto response = message->response()) {
330  response_id = next_response_id_++;
331  pending_responses_[response_id] = response;
332  }
333 
335  tonic::DartInvoke(dispatch_platform_message_.Get(),
336  {tonic::ToDart(message->channel()), data_handle,
337  tonic::ToDart(response_id)}));
338 }
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:20
const std::weak_ptr< DartState > & dart_state() const
#define FML_DLOG(severity)
Definition: logging.h:85
Dart_Handle ToDart(const T &object)
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

◆ DispatchSemanticsAction()

void flutter::PlatformConfiguration::DispatchSemanticsAction ( int32_t  id,
SemanticsAction  action,
fml::MallocMapping  args 
)

Notifies the framework that the embedder encountered an accessibility related action on the specified node. This call originates on the platform view and has been forwarded to the platform configuration here by the engine.

Parameters
[in]idThe identifier of the accessibility node.
[in]actionThe accessibility related action performed on the node of the specified ID.
[in]argsOptional data that applies to the specified action.

Definition at line 340 of file platform_configuration.cc.

References tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), tonic::DartPersistentValue::Get(), fml::MallocMapping::GetSize(), tonic::LogIfError(), and tonic::ToDart().

342  {
343  std::shared_ptr<tonic::DartState> dart_state =
344  dispatch_semantics_action_.dart_state().lock();
345  if (!dart_state) {
346  return;
347  }
348  tonic::DartState::Scope scope(dart_state);
349 
350  Dart_Handle args_handle =
351  (args.GetSize() <= 0) ? Dart_Null() : ToByteData(args);
352 
353  if (Dart_IsError(args_handle)) {
354  return;
355  }
356 
358  dispatch_semantics_action_.Get(),
359  {tonic::ToDart(id), tonic::ToDart(static_cast<int32_t>(action)),
360  args_handle}));
361 }
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:20
size_t GetSize() const override
Definition: mapping.cc:129
SemanticsAction action
const std::weak_ptr< DartState > & dart_state() const
Dart_Handle ToDart(const T &object)
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

◆ get_window()

Window* flutter::PlatformConfiguration::get_window ( int  window_id)
inline

Retrieves the Window with the given ID managed by the PlatformConfiguration.

Parameters
[in]window_idThe id of the window to find and return.
Returns
a pointer to the Window.

Definition at line 420 of file platform_configuration.h.

Referenced by flutter::Scene::create(), flutter::Canvas::drawShadow(), and flutter::testing::TEST_F().

420 { return windows_[window_id].get(); }

◆ operator=()

PlatformConfiguration& flutter::PlatformConfiguration::operator= ( const PlatformConfiguration )
delete

◆ RegisterKeyDataResponse()

uint64_t flutter::PlatformConfiguration::RegisterKeyDataResponse ( KeyDataResponse  callback)

Registers a callback to be invoked when the framework has decided whether to handle an event. This callback originates in the platform view and has been forwarded through the engine to here.

This method will move and store the callback, associate it with a self-incrementing identifier, the response ID, then return the ID, which is typically used by Window::DispatchKeyDataPacket.

Parameters
[in]callbackThe callback to be registered.
Returns
The response ID to be associated with the callback. Using this ID in CompleteKeyDataResponse will invoke the callback.

Definition at line 363 of file platform_configuration.cc.

364  {
365  uint64_t response_id = next_key_response_id_++;
366  pending_key_responses_[response_id] = std::move(callback);
367  return response_id;
368 }
FlKeyEvent FlKeyResponderAsyncCallback callback

◆ RegisterNatives()

void flutter::PlatformConfiguration::RegisterNatives ( tonic::DartLibraryNatives natives)
static

Registers the native handlers for Dart functions that this class handles.

Parameters
[in]nativesThe natives registry that the functions will be registered with.

Definition at line 489 of file platform_configuration.cc.

References flutter::_ComputePlatformResolvedLocale(), and tonic::DartLibraryNatives::Register().

Referenced by flutter::DartUI::InitForGlobal().

490  {
491  natives->Register({
492  {"PlatformConfiguration_defaultRouteName", DefaultRouteName, 1, true},
493  {"PlatformConfiguration_scheduleFrame", ScheduleFrame, 1, true},
494  {"PlatformConfiguration_sendPlatformMessage", _SendPlatformMessage, 4,
495  true},
496  {"PlatformConfiguration_respondToPlatformMessage",
497  _RespondToPlatformMessage, 3, true},
498  {"PlatformConfiguration_respondToKeyData", _RespondToKeyData, 3, true},
499  {"PlatformConfiguration_render", Render, 3, true},
500  {"PlatformConfiguration_updateSemantics", UpdateSemantics, 2, true},
501  {"PlatformConfiguration_setIsolateDebugName", SetIsolateDebugName, 2,
502  true},
503  {"PlatformConfiguration_reportUnhandledException",
504  ReportUnhandledException, 2, true},
505  {"PlatformConfiguration_setNeedsReportTimings", SetNeedsReportTimings, 2,
506  true},
507  {"PlatformConfiguration_getPersistentIsolateData",
508  GetPersistentIsolateData, 1, true},
509  {"PlatformConfiguration_computePlatformResolvedLocale",
511  });
512 }
static void _ComputePlatformResolvedLocale(Dart_NativeArguments args)
void Register(std::initializer_list< Entry > entries)

◆ ReportTimings()

void flutter::PlatformConfiguration::ReportTimings ( std::vector< int64_t >  timings)

Dart code cannot fully measure the time it takes for a specific frame to be rendered. This is because Dart code only runs on the UI task runner. That is only a small part of the overall frame workload. The raster task runner frame workload is executed on a thread where Dart code cannot run (and hence instrument). Besides, due to the pipelined nature of rendering in Flutter, there may be multiple frame workloads being processed at any given time. However, for non-Timeline based profiling, it is useful for trace collection and processing to happen in Dart. To do this, the raster task runner frame workloads need to be instrumented separately. After a set number of these profiles have been gathered, they need to be reported back to Dart code. The engine reports this extra instrumentation information back to the framework by invoking this method at predefined intervals.

See also
FrameTiming
Parameters
[in]timingsCollection of FrameTiming::kStatisticsCount * 'n' values for n frames whose timings have not been reported yet. Many of the values are timestamps, but a collection of integers is reported here for easier conversions to Dart objects. The timestamps are measured against the system monotonic clock measured in microseconds.

Definition at line 392 of file platform_configuration.cc.

References tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), FML_CHECK, FML_DCHECK, tonic::DartPersistentValue::Get(), tonic::LogIfError(), and type.

392  {
393  std::shared_ptr<tonic::DartState> dart_state =
394  report_timings_.dart_state().lock();
395  if (!dart_state) {
396  return;
397  }
398  tonic::DartState::Scope scope(dart_state);
399 
400  Dart_Handle data_handle =
401  Dart_NewTypedData(Dart_TypedData_kInt64, timings.size());
402 
403  Dart_TypedData_Type type;
404  void* data = nullptr;
405  intptr_t num_acquired = 0;
406  FML_CHECK(!Dart_IsError(
407  Dart_TypedDataAcquireData(data_handle, &type, &data, &num_acquired)));
408  FML_DCHECK(num_acquired == static_cast<int>(timings.size()));
409 
410  memcpy(data, timings.data(), sizeof(int64_t) * timings.size());
411  FML_CHECK(Dart_TypedDataReleaseData(data_handle));
412 
413  tonic::LogIfError(tonic::DartInvoke(report_timings_.Get(), {
414  data_handle,
415  }));
416 }
KeyCallType type
#define FML_DCHECK(condition)
Definition: logging.h:86
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:20
const std::weak_ptr< DartState > & dart_state() const
#define FML_CHECK(condition)
Definition: logging.h:68
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

◆ UpdateAccessibilityFeatures()

void flutter::PlatformConfiguration::UpdateAccessibilityFeatures ( int32_t  flags)

Forward the preference of accessibility features that must be enabled in the semantics tree to the framwork.

Parameters
[in]flagsThe accessibility features that must be generated in the semantics tree.

Definition at line 296 of file platform_configuration.cc.

References tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), tonic::DartPersistentValue::Get(), tonic::LogIfError(), and tonic::ToDart().

296  {
297  std::shared_ptr<tonic::DartState> dart_state =
298  update_accessibility_features_.dart_state().lock();
299  if (!dart_state) {
300  return;
301  }
302  tonic::DartState::Scope scope(dart_state);
303 
304  tonic::LogIfError(tonic::DartInvoke(update_accessibility_features_.Get(),
305  {tonic::ToDart(values)}));
306 }
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:20
const std::weak_ptr< DartState > & dart_state() const
Dart_Handle ToDart(const T &object)
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

◆ UpdateLifecycleState()

void flutter::PlatformConfiguration::UpdateLifecycleState ( const std::string &  data)

Updates the lifecycle state data in the framework.

Parameters
[in]dataThe lifecycle state data.

Definition at line 270 of file platform_configuration.cc.

References tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), tonic::DartPersistentValue::Get(), tonic::LogIfError(), and tonic::StdStringToDart().

270  {
271  std::shared_ptr<tonic::DartState> dart_state =
272  update_lifecycle_state_.dart_state().lock();
273  if (!dart_state) {
274  return;
275  }
276  tonic::DartState::Scope scope(dart_state);
277  tonic::LogIfError(tonic::DartInvoke(update_lifecycle_state_.Get(),
278  {
280  }));
281 }
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:20
const std::weak_ptr< DartState > & dart_state() const
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15
Dart_Handle StdStringToDart(const std::string &val)

◆ UpdateLocales()

void flutter::PlatformConfiguration::UpdateLocales ( const std::vector< std::string > &  locales)

Update the specified locale data in the framework.

Parameters
[in]locale_dataThe locale data. This should consist of groups of 4 strings, each group representing a single locale.

Definition at line 240 of file platform_configuration.cc.

References tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), tonic::DartPersistentValue::Get(), and tonic::LogIfError().

241  {
242  std::shared_ptr<tonic::DartState> dart_state =
243  update_locales_.dart_state().lock();
244  if (!dart_state) {
245  return;
246  }
247 
248  tonic::DartState::Scope scope(dart_state);
250  tonic::DartInvoke(update_locales_.Get(),
251  {
252  tonic::ToDart<std::vector<std::string>>(locales),
253  }));
254 }
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:20
const std::weak_ptr< DartState > & dart_state() const
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

◆ UpdateSemanticsEnabled()

void flutter::PlatformConfiguration::UpdateSemanticsEnabled ( bool  enabled)

Notifies the PlatformConfiguration that the embedder has expressed an opinion about whether the accessibility tree should be generated or not. This call originates in the platform view and is forwarded to the PlatformConfiguration here by the engine.

Parameters
[in]enabledWhether the accessibility tree is enabled or disabled.

Definition at line 283 of file platform_configuration.cc.

References tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), tonic::DartPersistentValue::Get(), tonic::LogIfError(), flutter::UIDartState::ThrowIfUIOperationsProhibited(), and tonic::ToDart().

283  {
284  std::shared_ptr<tonic::DartState> dart_state =
285  update_semantics_enabled_.dart_state().lock();
286  if (!dart_state) {
287  return;
288  }
289  tonic::DartState::Scope scope(dart_state);
291 
292  tonic::LogIfError(tonic::DartInvoke(update_semantics_enabled_.Get(),
293  {tonic::ToDart(enabled)}));
294 }
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:20
const std::weak_ptr< DartState > & dart_state() const
static void ThrowIfUIOperationsProhibited()
Dart_Handle ToDart(const T &object)
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

◆ UpdateUserSettingsData()

void flutter::PlatformConfiguration::UpdateUserSettingsData ( const std::string &  data)

Update the user settings data in the framework.

Parameters
[in]dataThe user settings data.

Definition at line 256 of file platform_configuration.cc.

References tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), tonic::DartPersistentValue::Get(), tonic::LogIfError(), and tonic::StdStringToDart().

256  {
257  std::shared_ptr<tonic::DartState> dart_state =
258  update_user_settings_data_.dart_state().lock();
259  if (!dart_state) {
260  return;
261  }
262  tonic::DartState::Scope scope(dart_state);
263 
264  tonic::LogIfError(tonic::DartInvoke(update_user_settings_data_.Get(),
265  {
267  }));
268 }
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:20
const std::weak_ptr< DartState > & dart_state() const
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15
Dart_Handle StdStringToDart(const std::string &val)

The documentation for this class was generated from the following files: