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

Both pages are rebuilding when there is a transition between pages #186

Open
alperenekin opened this issue Apr 24, 2024 · 0 comments
Open
Labels
bug Something isn't working in triage Sheet Page as Widget Issues will be answered under this theme

Comments

@alperenekin
Copy link

alperenekin commented Apr 24, 2024

Bug report

Describe the bug
In WoltModalSheet when there is a transition from one page to another, both of the pages are rebuilding.

Steps to reproduce

For example in Coffee Maker App:

return [
        AddWaterDescriptionModalPage.build(
          onNextPage: goToNextPage,
          onCancelPressed: () {
            model.onCoffeeOrderStatusChange(coffeeOrderId);
            Navigator.pop(context);
          },
          onClosed: Navigator.of(context).pop,
        ),
        WaterSettingsModalPage.build(
          onBackButtonPressed: goToPreviousPage,
          onClosed: Navigator.of(context).pop,
          onWaterAdded: () {
            model.onCoffeeOrderStatusChange(
                coffeeOrderId, CoffeeMakerStep.ready);
            Navigator.pop(context);
          },
        )
      ];
class AddWaterDescriptionModalPage {
  AddWaterDescriptionModalPage._();

  static WoltModalSheetPage build({
    required VoidCallback onCancelPressed,
    required VoidCallback onNextPage,
    required VoidCallback onClosed,
  }) {
    return WoltModalSheetPage(
     
      child: Builder(builder: (context) {
        print('Rebuild AddWaterDescriptionModalPage');
        return const Padding(
class WaterSettingsModalPage {
  WaterSettingsModalPage._();

  static WoltModalSheetPage build({
    required VoidCallback onBackButtonPressed,
    required VoidCallback onClosed,
    required VoidCallback onWaterAdded,
  }) {
    final buttonEnabledListener = ValueNotifier(false);

    return WoltModalSheetPage(

      child: Builder(builder: (context) {
        print('Rebuild WaterSettingsModalPage');
        return Padding(...

When I transition from AddWaterDescriptionModalPage to WaterSettingsModalPage the console output is:
image
When I transition back:
image

This is especially problem when I want to use Bloc specific to a dialog page like:

      WoltModalSheetPage(
      child: BlocProvider(
        create: (context) => TestBloc(),

Which ends up creating the bloc multiple times.

Expected behavior

The page should be drawn once and not rebuild unless it is triggered.

Please let me know if there is a way to handle this behaviour.
Thanks a lot

@alperenekin alperenekin added bug Something isn't working in triage labels Apr 24, 2024
@ulusoyca ulusoyca added the Sheet Page as Widget Issues will be answered under this theme label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in triage Sheet Page as Widget Issues will be answered under this theme
Projects
None yet
Development

No branches or pull requests

2 participants