mirror of
https://github.com/Cateners/tiny_computer.git
synced 2026-05-21 00:45:49 +08:00
Merge pull request #475 from Nriver/master
适配 Flutter 3.38+:使用官方 AssetManifest API 替换已移除的 json
This commit is contained in:
@@ -612,7 +612,14 @@ chmod 1777 tmp
|
|||||||
Util.createDirFromString("${G.dataPath}/containers/0/.l2s");
|
Util.createDirFromString("${G.dataPath}/containers/0/.l2s");
|
||||||
//这个是容器rootfs,被split命令分成了xa*,放在assets里
|
//这个是容器rootfs,被split命令分成了xa*,放在assets里
|
||||||
//首次启动,就用这个,别让用户另选了
|
//首次启动,就用这个,别让用户另选了
|
||||||
for (String name in jsonDecode(await rootBundle.loadString('AssetManifest.json')).keys.where((String e) => e.startsWith("assets/xa")).map((String e) => e.split("/").last).toList()) {
|
//使用 AssetManifest API 获取 assets/xa* 文件列表
|
||||||
|
final AssetManifest manifest = await AssetManifest.loadFromAssetBundle(rootBundle);
|
||||||
|
final List<String> xaFiles = manifest
|
||||||
|
.listAssets()
|
||||||
|
.where((String key) => key.startsWith('assets/xa'))
|
||||||
|
.map((String key) => key.split('/').last)
|
||||||
|
.toList();
|
||||||
|
for (String name in xaFiles) {
|
||||||
await Util.copyAsset("assets/$name", "${G.dataPath}/$name");
|
await Util.copyAsset("assets/$name", "${G.dataPath}/$name");
|
||||||
}
|
}
|
||||||
//-J
|
//-J
|
||||||
|
|||||||
Reference in New Issue
Block a user