Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug report] Inconsistent Import Aliases with @FFAutoImport() #41

Closed
lvyandev opened this issue Sep 26, 2024 · 4 comments
Closed

[Bug report] Inconsistent Import Aliases with @FFAutoImport() #41

lvyandev opened this issue Sep 26, 2024 · 4 comments

Comments

@lvyandev
Copy link

Version

2.1.0

Platforms

dart

Device Model

Galaxy SM9550

flutter info

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.1, on macOS 14.6.1 23G93 darwin-arm64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Android Studio (version 2024.1)
[✓] IntelliJ IDEA Community Edition (version 2023.2.6)
[✓] VS Code (version 1.93.1)
[✓] Connected device (2 available)

How to reproduce?

@FFAutoImport() annotation adds an alias to the generated import path for an enum, such as:

import 'package:src/constants/business_type.dart'
    as autoimport639f19359c5823a42058ed1022a12a9f;

In some parts of the generated code, the alias is used, while in others it is not, causing type conversion errors. This issue is particularly noticeable when an enum (in this case, BusinessType) has a default value in the constructor, as shown below:

pageType:
      asT<autoimport639f19359c5823a42058ed1022a12a9f.BusinessType>(
            safeArguments['pageType'],
            BusinessType.add,
          )!,

This inconsistency leads to compilation errors.

Steps to Reproduce:

Use @FFAutoImport() to import an enum with a default value in its constructor.
Attempt to use the enum in various parts of the generated code.
Compile the project and observe the type conversion errors.

Expected Result: The generated import paths for enums, especially those with default values in constructors, should maintain consistency. Either all should have aliases or none, to avoid type errors.

Logs

No response

Example code (optional)

No response

Contact

No response

@zmtzawqlp zmtzawqlp transferred this issue from fluttercandies/ff_annotation_route_core Sep 26, 2024
@zmtzawqlp
Copy link
Member

zmtzawqlp commented Sep 26, 2024

which version do you use? ff_annotation_route, and which mode do you use? fast or non-fast?

@zmtzawqlp
Copy link
Member

i can't reproduce at my side, do you use the latest of ff_annotation_route? if yes, please provide a simple demo , thanks

@lvyandev
Copy link
Author

ff_annotation_route 10.0.10

--no-fast-mode --output routes --routes-file-output routes -s

@lvyandev
Copy link
Author

update to

ff_annotation_route 10.1.0 (was 10.0.10)
ff_annotation_route_core 2.1.0 (was 2.0.7)

problem solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants