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

app.dialogs.dart resets after running stacked generate #1125

Closed
pieterbergmans opened this issue Sep 10, 2024 · 4 comments
Closed

app.dialogs.dart resets after running stacked generate #1125

pieterbergmans opened this issue Sep 10, 2024 · 4 comments

Comments

@pieterbergmans
Copy link

Describe the bug

Hi,

I’m trying to add a custom dialog called languages. But after I run stacked generate, the code disappears. Is that the intent or am I doing something wrong. The same thing happens with bottomSheets.

My new dialog service…

enum DialogType { infoAlert, languages }

void setupDialogUi() {
  final dialogService = locator<DialogService>();

  final Map<DialogType, DialogBuilder> builders = {
    DialogType.infoAlert: (context, request, completer) =>
        InfoAlertDialog(request: request, completer: completer),
    DialogType.languages: (context, request, completer) => LanguagesDialog(
          request: request,
          completer: completer,
        )
  };

  dialogService.registerCustomDialogBuilders(builders);
}

After running stacked generate

enum DialogType {
  infoAlert,
}

void setupDialogUi() {
  final dialogService = locator<DialogService>();

  final Map<DialogType, DialogBuilder> builders = {
    DialogType.infoAlert: (context, request, completer) =>
        InfoAlertDialog(request: request, completer: completer),
  };

  dialogService.registerCustomDialogBuilders(builders);
}

What operating system do you use?

macOS

Information about the installed tooling

// pubspec.yaml
stacked: ^3.4.0
stacked_services: ^1.1.0
stacked_themes:

// flutter doctor
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.4 23E214 darwin-arm64 (Rosetta), locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Xcode - develop for iOS and macOS (Xcode 15.4)
    ✗ Unable to get list of installed Simulator runtimes.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.91.1)
[✓] Connected device (3 available)
[✓] Network resources

Steps to reproduce the issue

  1. Add custom dialog
  2. run stacked generate

Expected behavior

I would have expected that the app.diaglogs.dart file to maintain the new custom dialog information.

Screenshots

No response

Additional Context

No response

@pieterbergmans
Copy link
Author

Sorry, I just read the message // GENERATED CODE - DO NOT MODIFY BY HAND at the top of the app.dialogs.dart page. However, I’d still like help explaining how to create a custom dialog.

@pieterbergmans
Copy link
Author

Just figured it out. I needed to add the following to app.dart:

dialogs: [
    StackedDialog(classType: InfoAlertDialog),
    StackedDialog(classType: LanguagesDialog)
    // @stacked-dialog
  ],

@sebastianbuechler
Copy link
Contributor

@pieterbergmans So this can be closed, right?

@pieterbergmans
Copy link
Author

@sebastianbuechler - yes, it can.

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

3 participants