AoEiuV020JP
0.1D
V2EX  ›  Flutter

Flutter assets 资源大文件读取卡 ui 有办法吗?

  •  
  •   AoEiuV020JP · Sep 8, 2023 · 1542 views
    This topic created in 1028 days ago, the information mentioned may be changed or developed.
    原生开发这种问题丢到异步线程就搞定了,但 flutter 就各种坑,
    AssetBundle 只提供 loadString 和 load 两个方法,哪一个都是一次性读取所有字节到内存,这一步卡顿似乎没法优化掉,
    如果把 AssetBundle 放到异步调用 load 又报错“Binding has not yet been initialized.”,
    让我调用 WidgetsFlutterBinding.ensureInitialized()但调了还是一样,

    总之有没什么办法处理这个 assets 大文件读取?要么能异步读取,要么就转 Stream 分片读取,

    完整代码,看有没什么办法能优化的,
    https://github.com/AoEiuV020/TaikoSongs/blob/2d678c68a8e1f0d464df1cef2ba7f49f66d88b16/lib/src/irondb/impl/database_assets.dart#L45
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4970 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 09:39 · PVG 17:39 · LAX 02:39 · JFK 05:39
    ♥ Do have faith in what you're doing.