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

[stacked_generator] Missing prefix of enum default value in app.router.dart #745

Closed
cvphat opened this issue Oct 25, 2022 · 11 comments · Fixed by #757
Closed

[stacked_generator] Missing prefix of enum default value in app.router.dart #745

cvphat opened this issue Oct 25, 2022 · 11 comments · Fixed by #757
Assignees
Labels
p1 Highest priority issue

Comments

@cvphat
Copy link

cvphat commented Oct 25, 2022

I have a view with default value is an enum in constructor like this:

class CameraView extends StatelessWidget {
  final List<CameraMode> cameraModes;
  final bool allowSwitchCamera;
  const CameraView({
    super.key,
    this.cameraModes = const [
      CameraMode.image,
      CameraMode.video,
    ],
    this.allowSwitchCamera = false,
  });
}

app.router.dart
image

@FilledStacks
Copy link
Contributor

Hi there, thanks for filing an issue. We have fixed this before. Can you confirm the version of the stacked_generator that you're currently using in your pubspec.yaml?

@cvphat
Copy link
Author

cvphat commented Oct 26, 2022

Hi there, thanks for filing an issue. We have fixed this before. Can you confirm the version of the stacked_generator that you're currently using in your pubspec.yaml?

I am using ^0.8.0+1

@FilledStacks
Copy link
Contributor

Aaaah, I see. The default value as a list of enums is what breaks it. Normal enums work. When I get some time I'll fix this up. I might only get time in the next few days.

@FilledStacks FilledStacks added the p1 Highest priority issue label Oct 26, 2022
@eb-so eb-so self-assigned this Nov 10, 2022
@ScottAtRedHawk
Copy link

ScottAtRedHawk commented Nov 10, 2022

Hi @eb-so , this is also an issue with importing prefixes on routes with type parameters. The import and prefix are at the top of the app.router.dart file but not put with the classes. After every build runner build command, I have to manually fix the prefixes.

Thanks!

app.dart

@StackedApp(
  routes: [
    AdaptiveRoute(page: StartupView, initial: true),
    CustomRoute(
      page: LoginView,
      transitionsBuilder: TransitionsBuilders.slideTop,
      durationInMilliseconds: 300,
    ),
    AdaptiveRoute<Customer>(page: CustomerSelectionView),
    AdaptiveRoute<CategoryType>(page: CategorySelectionView),
  ],
  dependencies: [
    // stacked services
    LazySingleton(classType: NavigationService),
  ],
  logger: StackedLogger(),
)
class App {
  // This class has no purpose besides housing the annotation that generates
  // the required functionality.
}

image

@FilledStacks
Copy link
Contributor

Please confirm it works on 0.8.1-beta.3 @cvphat then I'll promote to stable.

@cvphat
Copy link
Author

cvphat commented Nov 14, 2022

@FilledStacks , It does not work. I also tried to run flutter clean and flutter pub get again.

@eb-so
Copy link
Contributor

eb-so commented Nov 14, 2022

@cvphat I used this example to repreduce the bug

@cvphat
Copy link
Author

cvphat commented Nov 14, 2022

The route method is also not correct after I upgrade to 0.8.1-beta.3
image
As image, the class name of view has not been capitalized the first character

@eb-so
Copy link
Contributor

eb-so commented Nov 14, 2022

I didn't change that but you can create a separate issue for it

@cvphat
Copy link
Author

cvphat commented Nov 14, 2022

@eb-so , I created a new repo to reproduce and added some code to generate router. The bug is still happening. Please help to see this https://github.com/cvphat/stacked_issue
image
I do not know why your example code work well 😢

@eb-so
Copy link
Contributor

eb-so commented Nov 14, 2022

@cvphat I found the issue, I'll fix it quickly

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

Successfully merging a pull request may close this issue.

4 participants