FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
131 stars 26 forks source link

Cannot import component in custom widget #4986

Open AdrKacz opened 5 days ago

AdrKacz commented 5 days ago

Can we access your project?

Current Behavior

When you want to import one of your components in a custom widget code, you'll notice the compilation doesn't work, however running the project works fine, which demonstrate that the compilation step in the code editor is not working fine.

You can find multiple issue on the community about this bug, see this one from more than a year ago for example: https://community.flutterflow.io/custom-code/post/how-to-call-another-component-within-a-custom-widget-i22gxgy4BjsCUqp

Expected Behavior

I expect the compilation and the actual run to either both work or both fail. Moreover, I don't expect the compilation to fail with an "cannot find file" where the file is actually there.

Steps to Reproduce

  1. Create a project
  2. Add a component
  3. Create a custom widget, add the import import '<path to your components>';
  4. Try to compile and verify it fails
  5. Run the project and verify it works

Reproducible from Blank

Bug Report Code (Required)

Not applicable

Visual documentation

See community forum.

Environment

- FlutterFlow version: 5.0.13
- Platform: Desktop and Chrome
- Browser name and version: Chrome 131.0.6778.86
- Operating system and version affected: MacOS

Additional Information

No response

Alezanello commented 5 days ago

Hello!

In this case, you can enable the "Exclude from Compilation" option in the right toolbar. This will prevent the error from appearing in the builder. Please note that this option is specifically for bypassing error checks during compilation.

AdrKacz commented 5 days ago

Thank you for your response!

While selecting "Exclude from compilation" does silence the errors, it still makes working with custom widgets more challenging.

Could you provide some context on why custom widgets don’t support file imports? When exporting the code, the component's code is included and the import statements don't raise errors.

Could this be due to the compilation environment in FF for custom widgets being different from the runtime environment? If so, could you share any additional details about this?

Thank you!

Alezanello commented 5 days ago

That's a great question! Unfortunately, I don’t have full insight into how the engineering team sets up the environment inside FlutterFlow files. It’s possible that the file paths differ from their structure when the code is downloaded. This could be why the editor has trouble locating custom widgets when they are added.

AdrKacz commented 4 days ago

Thank you for details. Any chance you could bring this information to the engineering team so we can make sure they made the relative path not available on purpose please? As this might just be a small typo in the path resolution or working folder they use.