|
9 | 9 | import android.support.annotation.NonNull; |
10 | 10 |
|
11 | 11 | import io.flutter.embedding.engine.FlutterEngine; |
| 12 | +import io.flutter.embedding.engine.loader.FlutterLoader; |
12 | 13 | import io.flutter.plugin.common.BinaryMessenger; |
13 | 14 | import io.flutter.plugin.platform.PlatformViewRegistry; |
14 | 15 | import io.flutter.view.TextureRegistry; |
@@ -91,19 +92,22 @@ class FlutterPluginBinding { |
91 | 92 | private final BinaryMessenger binaryMessenger; |
92 | 93 | private final TextureRegistry textureRegistry; |
93 | 94 | private final PlatformViewRegistry platformViewRegistry; |
| 95 | + private final FlutterAssets flutterAssets; |
94 | 96 |
|
95 | 97 | public FlutterPluginBinding( |
96 | 98 | @NonNull Context applicationContext, |
97 | 99 | @NonNull FlutterEngine flutterEngine, |
98 | 100 | @NonNull BinaryMessenger binaryMessenger, |
99 | 101 | @NonNull TextureRegistry textureRegistry, |
100 | | - @NonNull PlatformViewRegistry platformViewRegistry |
| 102 | + @NonNull PlatformViewRegistry platformViewRegistry, |
| 103 | + @NonNull FlutterAssets flutterAssets |
101 | 104 | ) { |
102 | 105 | this.applicationContext = applicationContext; |
103 | 106 | this.flutterEngine = flutterEngine; |
104 | 107 | this.binaryMessenger = binaryMessenger; |
105 | 108 | this.textureRegistry = textureRegistry; |
106 | 109 | this.platformViewRegistry = platformViewRegistry; |
| 110 | + this.flutterAssets = flutterAssets; |
107 | 111 | } |
108 | 112 |
|
109 | 113 | @NonNull |
@@ -136,5 +140,47 @@ public TextureRegistry getTextureRegistry() { |
136 | 140 | public PlatformViewRegistry getPlatformViewRegistry() { |
137 | 141 | return platformViewRegistry; |
138 | 142 | } |
| 143 | + |
| 144 | + @NonNull |
| 145 | + public FlutterAssets getFlutterAssets() { |
| 146 | + return flutterAssets; |
| 147 | + } |
139 | 148 | } |
| 149 | + |
| 150 | + /** |
| 151 | + * Provides Flutter plugins with access to Flutter asset information. |
| 152 | + */ |
| 153 | + interface FlutterAssets { |
| 154 | + /** |
| 155 | + * Returns the relative file path to the Flutter asset with the given name, including the file's |
| 156 | + * extension, e.g., {@code "myImage.jpg"}. |
| 157 | + * |
| 158 | + * <p>The returned file path is relative to the Android app's standard assets directory. |
| 159 | + * Therefore, the returned path is appropriate to pass to Android's {@code AssetManager}, |
| 160 | + * but the path is not appropriate to load as an absolute path. |
| 161 | + */ |
| 162 | + String getAssetFilePathByName(@NonNull String assetFileName); |
| 163 | + |
| 164 | + /** |
| 165 | + * Same as {@link #getAssetFilePathByName(String)} but with added support for an explicit |
| 166 | + * Android {@code packageName}. |
| 167 | + */ |
| 168 | + String getAssetFilePathByName(@NonNull String assetFileName, @NonNull String packageName); |
| 169 | + |
| 170 | + /** |
| 171 | + * Returns the relative file path to the Flutter asset with the given subpath, including the file's |
| 172 | + * extension, e.g., {@code "/dir1/dir2/myImage.jpg"}. |
| 173 | + * |
| 174 | + * <p>The returned file path is relative to the Android app's standard assets directory. |
| 175 | + * Therefore, the returned path is appropriate to pass to Android's {@code AssetManager}, |
| 176 | + * but the path is not appropriate to load as an absolute path. |
| 177 | + */ |
| 178 | + String getAssetFilePathBySubpath(@NonNull String assetSubpath); |
| 179 | + |
| 180 | + /** |
| 181 | + * Same as {@link #getAssetFilePathBySubpath(String)} but with added support for an explicit |
| 182 | + * Android {@code packageName}. |
| 183 | + */ |
| 184 | + String getAssetFilePathBySubpath(@NonNull String assetSubpath, @NonNull String packageName); |
| 185 | + } |
140 | 186 | } |
0 commit comments