Assets Extension

Access (png, jpeg, svg) assets in easy way, you can access the asset file by name instead of full asset path.
  • svgAsset: assets/svgs/{svg}.svg
  • pngAsset: assets/images/{image}.png
  • webpAsset: assets/images/{image}.webp
  • gifAsset: assets/gifs/{GIF-image}.gif
class MyWidget extends StatelessWidget {
  const MyWidget({super.key});

  @override
  Widget build(BuildContext context) {
    // it equals to: Image.asset("assets/images/logo.png")
    return Image.asset("logo".pngAsset); // <-- add here
  }
}