manjav / particular

Enhance your app or game visuals with this high-performance Flutter Particles System widget
MIT License
8 stars 0 forks source link

default export doesn't work #3

Open Ahmadre opened 1 month ago

Ahmadre commented 1 month ago

I have a simple example and downloaded a configs.json file and I get this, when I start the app:

lutter: Unable to load asset: "assets/texture.png".
flutter: The asset does not exist or has empty data.
flutter: ----------------FIREBASE CRASHLYTICS----------------
flutter: Unable to load asset: "assets/texture.png".
The asset does not exist or has empty data.
flutter: 
#0      PlatformAssetBundle.load.<anonymous closure> (package:flutter/src/services/asset_bundle.dart:324:9)
<asynchronous suspension>
#1      ParticularController._getDefaultTexture (package:particular/src/particular_controller.dart:44:24)
<asynchronous suspension>
#2      ParticularController._add (package:particular/src/particular_controller.dart:153:29)
<asynchronous suspension>
#3      ParticularController.addLayer (package:particular/src/particular_controller.dart:123:9)
<asynchronous suspension>
flutter: ----------------------------------------------------

The editor only gave a json file 😓

I don't know why I need a texture.png?

Init Code:

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);

    WidgetsBinding.instance.addPostFrameCallback((_) async {
      // Load particle configs file
      String json = await rootBundle.loadString("assets/particles/configs.json");
      final configsData = jsonDecode(json);

      // Add particles layer
      _particleController.addLayer(
        configsData: configsData, // Remove in programmatic configuration case
      );
      setState(() {});
    });
  }
manjav commented 1 month ago

Particular editor doesn't know the structure of your assets file in your project. so it generates default path for images. You can change textureFileName value to your own path, in the configs.json file.

"textureFileName": "images/particle_cover.webp"

In addition considering add embed tag in pubspecs.yaml

  assets:
    - assets/images/
Ahmadre commented 1 month ago

Particular editor doesn't know the structure of your assets file in your project. so it generates default path for images. You can change textureFileName value to your own path, in the configs.json file.

"textureFileName": "images/particle_cover.webp"

In addition considering add embed tag in pubspecs.yaml

  assets:
    - assets/images/

Then you're not creating particles with your editor...I'm confused...

imaNNeo commented 1 month ago

I think the editor uses this asset file as the texture, so you need to copy-paste it in your project.

But I think it would be a good idea to put the assets in the package itself, then you can access the 3rd party assets in the app using this method. This way, users don't need to copy-paste the texture in their projects.

manjav commented 1 month ago

Particular creates a JSON file that contains one or several particle layers. Each particle layer has a textureFileName field. The textureFileName field refers to the path of an image asset in your project. You can copy your uploaded image in the editor to your project.

In the next version, the option to download the layer texture will be available. Future versions may include options for image data, image asset paths, or image URLs in the editor. However, in the initial steps, we only have the image asset path option.