-
Notifications
You must be signed in to change notification settings - Fork 64
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
playground examples not working with one click #134
Comments
Thanks for the report. It looks like 0.4.0 has issues. 0.3.0 should still be working. We are on it. |
@AcarFurkan We found out the root cause, and we will release the hotfix tomorrow. |
@ulusoyca First of all, thank you for your attention so quickly :) I also found the reason why the error did not occur in the past but now. Actually, the |
Thanks for checking the issue. Yes this is because of the lines you pointed.
Before 0.4.0, the state management through the decorator widget worked well as long as the same widgets are used for different states. When the state changes, if the page content completely changes, these changes would not be reflected because the current page widgets are not re-created. For example, this would not work ( pageListBuilder: (context) {
final viewModel = context.watch<TaskItemHistoryDetailViewModel>();
final state = viewModel.state;
return [
SliverWoltModalSheetPage(
mainContentSlivers: state.viewState.when(
loading: () => const [
SliverToBoxAdapter(
child: Center(
child: Padding(
padding: EdgeInsets.all(sp16),
child: LoadingIndicator(size: _loadingIndicatorSize),
),
),
),
],
idle: () => TaskItemDetailModalContent.createSlivers(
aggregatedItem: aggregatedTaskItemHistory,
options: state.taskItemOptionsHistory.options,
),
error: () => [
SliverToBoxAdapter(
child: FullScreenErrorWidget(
error: state.error ?? ParsedError(error: Object()),
action: () => viewModel.onInit(
aggregatedTaskItemHistory,
selectedPastOrdersFilterSet,
),
),
),
],
),
),
];
}, My change attempted to re-create current pages everytime the page state changed, but this ended up losing the states of the current widgets. We should have done better testing. Anyway, a hotfix is coming. The best way to update the widgets according to state:
This workaround would work. return WoltModalSheet.show(
context: context,
pageListBuilder: (context) {
final viewModel = context.read<TaskItemHistoryDetailViewModel>();
return [
WoltModalSheetPage(
child: ListenableBuilder(
listenable: viewModel,
builder: (context, _) {
final state = viewModel.state;
final viewState = state.viewState;
return viewState.when(
loading: () => const Center(
child: Padding(
padding: EdgeInsets.all(sp16),
child: LoadingIndicator(size: _loadingIndicatorSize),
),
),
idle: () => TaskItemDetailModalContent(
aggregatedItem: aggregatedTaskItemHistory,
options: state.taskItemOptionsHistory.options,
),
error: () => FullScreenErrorWidget(
error: state.error ?? ParsedError(error: Object()),
action: () => viewModel.onInit(
aggregatedTaskItemHistory,
selectedPastOrdersFilterSet,
),
),
);
},
),
),
];
},
decorator: (widget) => ViewModelProvider<TaskItemHistoryDetailViewModel>(
builder: (_, model, __) => widget,
onViewModelProvided: (viewModel) => viewModel.onInit(
aggregatedTaskItemHistory,
selectedPastOrdersFilterSet,
),
),
) The code above is for this screen: past_order_fix.mp4 |
I understand it better now, thank you very much :) Sometimes it can be very difficult to transfer projects to open source. While you can solve everything internally with your methods, it can be very difficult to open it up and make it work for everyone. But a more modular code will certainly emerge at the end of the day |
@AcarFurkan If we had integration tests in place, we would have been in safer spot. Working on it. Closing this as we reverted the root cause. |
Bug report
I take this error both in
playground
andplayground_navigator2
.After openingwolt_modal_sheet
, I cannot select an element in the list with a single click.In theplayground
example, I cannot select it at all. In theplayground_navigator2
example, I can select it with double click. I think the reason for this inplayground
is thatpageListBuilder
is called with every change, so it is rebuilt each time.wolt_modal_sheet/playground/lib/home/pages/multi_page_path_name.dart
Line 32 in 3da966e
I was going to look into how to fix this, but I didn't understand whether it was an undesirable behavior or whether it was done this way on purpose.
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
I think we should be able to select it with a click
The text was updated successfully, but these errors were encountered: