How do I get the Asset's file path in flutter?

后端 未结 2 2030
梦毁少年i
梦毁少年i 2020-12-16 00:46

Here is my pubspec.yaml:

  assets:
    - assets/mySecertImage.png

Here is how I read back the assets:

  var data = await Pl         


        
2条回答
  •  既然无缘
    2020-12-16 01:25

    You can not get the file path of an asset file, because assets, that are bundled with your app, are stored inside an archive.

    See the "Asset building" section here:

    https://flutter.dev/docs/development/ui/assets-and-images#asset-bundling

    During a build, Flutter places assets into a special archive called the asset bundle that apps read from at runtime.

提交回复
热议问题