[bug]: Unhandled Exception: 'package:stacked_services/src/bottom_sheet/bottom_sheet_service.dart': Failed assertion: line 113 pos 7: '_sheetBuilders != null
felixjaehn opened this issue · 1 comments
Describe the bug
Although the project has been set up through the stacked CLI and the setCustomSheetBuilders function is called in main.dart this error still occurs when first using the showCustomSheet function.
After digging a little bit into it, it seems like the private variable _sheetBuilders gets set, when calling the setCustomSheetBuilders function but somehow is null again, when the showCustomSheet function is called.
I do not know why this happens.
To reproduce
void setupBottomSheetUi() {
final bottomsheetService = locator<BottomSheetService>();
final Map<BottomSheetType, SheetBuilder> builders = {
BottomSheetType.notice: (context, request, completer) => NoticeSheet(request: request, completer: completer),
BottomSheetType.postDetails: (context, request, completer) => PostDetailsSheet(request: request, completer: completer),
};
bottomsheetService.setCustomSheetBuilders(builders);
}
void showPostDetails() {
_bottomSheetService.showCustomSheet(variant: BottomSheetType.notice);
}
Expected behavior
No response
Screenshots
No response
Additional Context
No response
Hi, this works when I generate a project with Stacked.
void showBottomSheet() {
_bottomSheetService.showCustomSheet(
variant: BottomSheetType.notice,
title: ksHomeBottomSheetTitle,
description: ksHomeBottomSheetDescription,
);
}
I see you're not passing in a title and description, make sure you're doing that and try again. Otherwise please generate a stacked project that reproduces this and share it with us so we can fix the bug.