Stacked-Org/stacked

[bug]: stacked generate - doesn't uses changes in stacked.json?

MacMeissner opened this issue · 2 comments

Describe the bug

I created a new Project with 'stacked create app _my_app'.

After that there is a stacked.json in the root folder. I changed the "locator_name": "sl" and
used 'stacked generate'.

Script is running and after that...nothing changed. The name of locator is 'locator'. Am i missing something?

-second try-
renaming the locator in app.locator.dart to 'sl'.
==> final sl = StackedLocator.instance;
Application runs. Everything ok.
But after running 'stacked generate' in terminal app.locator.dart recreated with the default name 'locator'
==> final locator = StackedLocator.instance;

To reproduce

  1. create an app: stacked create app _my_app
  2. cd app_my_app
  3. open .
  4. searching for stacked.json in root
  5. renaming "locator_name": "locator" to "locator_name": "sl"
  6. saving file
  7. goto terminal
  8. run 'stacked generate'
  9. locator name is still the default name

Expected behavior

Expectation is to have a new generated app.locator.dart file containing this line of code.

final sl = StackedLocator.instance;

Screenshots

No response

Additional Context

No response

Hi @MacMeissner , how are you? Sorry for the late response, we were busy with some projects.

As you can see on the documentation, locator_name is used when creating a new Service using the create service command.

To change the name of the locator in the app you have to change locatorName property in StackedApp annotation. For example:

@StackedApp(
  routes: [
    MaterialRoute(page: HomeView),
    MaterialRoute(page: StartupView),
    // @stacked-route
  ],
  dependencies: [
    LazySingleton(classType: BottomSheetService),
    LazySingleton(classType: DialogService),
    LazySingleton(classType: NavigationService),
    // @stacked-service
  ],
  bottomsheets: [
    StackedBottomsheet(classType: NoticeSheet),
    // @stacked-bottom-sheet
  ],
  dialogs: [
    StackedDialog(classType: InfoAlertDialog),
    // @stacked-dialog
  ],
  locatorName: 'sl',
)
class App {}

Can you try this please? Let me know if it works.

Any update on this @MacMeissner we want to close this issue if it's been resolved