Both pages are rebuilding when there is a transition between pages
alperenekin opened this issue · comments
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:
When I transition back:
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