Flutter Engine
Loading...
Searching...
No Matches
native_assets.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_ASSETS_NATIVE_ASSETS_H_
6
#define FLUTTER_ASSETS_NATIVE_ASSETS_H_
7
8
#include <memory>
9
#include <vector>
10
11
#include "
flutter/assets/asset_manager.h
"
12
13
namespace
flutter
{
14
15
// Parses the `NativeAssetsManifest.json` and provides a way to look up assets
16
// and the available assets for the callbacks that are registered to the Dart VM
17
// via the dart_api.h.
18
//
19
// The engine eagerly populates a native assets manager on startup. This native
20
// assets manager is stored in the `IsolateGroupData` so it can be accessed on
21
// the native assets callbacks registered in `InitDartFFIForIsolateGroup`.
22
class
NativeAssetsManager
{
23
public
:
24
NativeAssetsManager
() =
default
;
25
~NativeAssetsManager
() =
default
;
26
27
// Reads the `NativeAssetsManifest.json` bundled in the Flutter application.
28
void
RegisterNativeAssets
(
const
uint8_t* manifest,
size_t
manifest_size);
29
void
RegisterNativeAssets
(
const
std::shared_ptr<AssetManager>& asset_manager);
30
31
// Looks up the asset path for [asset_id].
32
//
33
// The asset path consists of a type, and an optional path. For example:
34
// `["system", "libsqlite3.so"]`.
35
std::vector<std::string>
LookupNativeAsset
(std::string_view asset_id);
36
37
// Lists the available asset ids.
38
//
39
// Used when a user tries to look up an asset with an ID that does not exist
40
// to report the list of available asset ids.
41
std::string
AvailableNativeAssets
();
42
43
private
:
44
std::unordered_map<std::string, std::vector<std::string>> parsed_mapping_;
45
46
NativeAssetsManager
(
const
NativeAssetsManager
&) =
delete
;
47
NativeAssetsManager
(
NativeAssetsManager
&&) =
delete
;
48
NativeAssetsManager
& operator=(
const
NativeAssetsManager
&) =
delete
;
49
NativeAssetsManager
& operator=(
NativeAssetsManager
&&) =
delete
;
50
};
51
52
}
// namespace flutter
53
54
#endif
// FLUTTER_ASSETS_NATIVE_ASSETS_H_
asset_manager.h
flutter::NativeAssetsManager
Definition
native_assets.h:22
flutter::NativeAssetsManager::RegisterNativeAssets
void RegisterNativeAssets(const uint8_t *manifest, size_t manifest_size)
Definition
native_assets.cc:46
flutter::NativeAssetsManager::NativeAssetsManager
NativeAssetsManager()=default
flutter::NativeAssetsManager::AvailableNativeAssets
std::string AvailableNativeAssets()
Definition
native_assets.cc:119
flutter::NativeAssetsManager::~NativeAssetsManager
~NativeAssetsManager()=default
flutter::NativeAssetsManager::LookupNativeAsset
std::vector< std::string > LookupNativeAsset(std::string_view asset_id)
Definition
native_assets.cc:108
flutter
Definition
asset_manager.cc:10
assets
native_assets.h
Generated on Thu Nov 6 2025 16:11:21 for Flutter Engine by
1.9.8