Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions shell/platform/embedder/embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1573,3 +1573,7 @@ FlutterEngineResult FlutterEngineUpdateLocales(FLUTTER_API_SYMBOL(FlutterEngine)
"Could not send message to update locale of "
"a running Flutter application.");
}

bool FlutterEngineRunsAOTCompiledDartCode(void) {
return flutter::DartVM::IsRunningPrecompiledCode();
}
20 changes: 20 additions & 0 deletions shell/platform/embedder/embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,26 @@ FlutterEngineResult FlutterEngineUpdateLocales(FLUTTER_API_SYMBOL(FlutterEngine)
const FlutterLocale** locales,
size_t locales_count);

//------------------------------------------------------------------------------
/// @brief Returns if the Flutter engine instance will run AOT compiled
/// Dart code. This call has no threading restrictions.
///
/// For embedder code that is configured for both AOT and JIT mode
/// Dart execution based on the Flutter engine being linked to, this
/// runtime check may be used to appropriately configure the
/// `FlutterProjectArgs`. In JIT mode execution, the kernel
/// snapshots must be present in the Flutter assets directory
/// specified in the `FlutterProjectArgs`. For AOT execution, the
/// fields `vm_snapshot_data`, `vm_snapshot_instructions`,
/// `isolate_snapshot_data` and `isolate_snapshot_instructions`
/// (along with their size fields) must be specified in
/// `FlutterProjectArgs`.
///
/// @return True, if AOT Dart code is run. JIT otherwise.
///
FLUTTER_EXPORT
bool FlutterEngineRunsAOTCompiledDartCode(void);

#if defined(__cplusplus)
} // extern "C"
#endif
Expand Down
5 changes: 5 additions & 0 deletions shell/platform/embedder/tests/embedder_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2809,5 +2809,10 @@ TEST_F(EmbedderTest, CanUpdateLocales) {
check_latch.Wait();
}

TEST_F(EmbedderTest, CanQueryDartAOTMode) {
ASSERT_EQ(FlutterEngineRunsAOTCompiledDartCode(),
flutter::DartVM::IsRunningPrecompiledCode());
}

} // namespace testing
} // namespace flutter