modal_bottom_sheet
modal_bottom_sheet copied to clipboard
Support multiple vertical scrollviews
If the bottom sheet contains multi ListViews and all of the ListViews attach to the ModalScrollController, then the bottom sheet cannot drag down to close.
By reviewing the source code, I found the limitation in modal_bottom_sheet-2.0.0/lib/src/bottom_sheet.dart:264
Any idea to deal with this?
Maybe you can use a CustomScrollView with multiple SliverList.
Only one active scroll view should be attached for the same scroll controller.
I haven't seen any case so far that requires two vertical scroll views as it is an unusual behavior for an app. I would love to hear more about your use case for this.
Only one active scroll view should be attached for the same scroll controller.
I haven't seen any case so far that requires two vertical scroll views as it is an unusual behavior for an app. I would love to hear more about your use case for this.
@jamesblasco I have this same issue
Error log
flutter: ══╡ EXCEPTION CAUGHT BY ANIMATION LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown while notifying status listeners for AnimationController:
flutter: The provided ScrollController is currently attached to more than one ScrollPosition.
flutter: The Scrollbar requires a single ScrollPosition in order to be painted.
flutter: When the scrollbar is interactive, the associated ScrollController must only have one ScrollPosition
flutter: attached.The provided ScrollController must be unique to one ScrollView widget.
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 RawScrollbarState._debugCheckHasValidScrollPosition.<anonymous closure>
flutter: #1 RawScrollbarState._debugCheckHasValidScrollPosition
flutter: #2 RawScrollbarState._validateInteractions
flutter: #3 AnimationLocalStatusListenersMixin.notifyStatusListeners
flutter: #4 AnimationController._checkStatusChanged
flutter: #5 AnimationController._startSimulation
flutter: #6 AnimationController._animateToInternal
flutter: #7 AnimationController.forward
flutter: #8 RawScrollbarState._handleScrollNotification
flutter: #9 _NotificationElement.onNotification
flutter: #10 _NotificationNode.dispatchNotification
flutter: #11 _NotificationNode.dispatchNotification
flutter: #12 Element.dispatchNotification
flutter: #13 Notification.dispatch
flutter: #14 DragScrollActivity.dispatchScrollUpdateNotification
flutter: #15 ScrollPosition.didUpdateScrollPositionBy
flutter: #16 ScrollPosition.setPixels
flutter: #17 ScrollPositionWithSingleContext.setPixels
flutter: #18 ScrollPositionWithSingleContext.applyUserOffset
flutter: #19 ScrollDragController.update
flutter: #20 ScrollableState._handleDragUpdate
flutter: #21 DragGestureRecognizer._checkUpdate.<anonymous closure>
flutter: #22 GestureRecognizer.invokeCallback
flutter: #23 DragGestureRecognizer._checkUpdate
flutter: #24 DragGestureRecognizer.handleEvent
flutter: #25 PointerRouter._dispatch
flutter: #26 PointerRouter._dispatchEventToRoutes.<anonymous closure>
flutter: #27 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:617:13)
flutter: #28 PointerRouter._dispatchEventToRoutes
flutter: #29 PointerRouter.route
flutter: #30 GestureBinding.handleEvent
flutter: #31 GestureBinding.dispatchEvent
flutter: #32 RendererBinding.dispatchEvent
flutter: #33 GestureBinding._handlePointerEventImmediately
flutter: #34 GestureBinding.handlePointerEvent
flutter: #35 GestureBinding._flushPointerEventQueue
flutter: #36 GestureBinding._handlePointerDataPacket
flutter: #37 _invoke1 (dart:ui/hooks.dart:167:13)
flutter: #38 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:341:7)
flutter: #39 _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)
flutter:
flutter: The AnimationController notifying status listeners was:
flutter: AnimationController#17b14(▶ 0.000)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: The provided ScrollController is currently attached to more than one ScrollPosition.
flutter: Another exception was thrown: The provided ScrollController is currently attached to more than one ScrollPosition.
Reloaded 1 of 3347 libraries in 1 624ms (compile: 91 ms, reload: 494 ms, reassemble: 994 ms).
flutter: ══╡ EXCEPTION CAUGHT BY ANIMATION LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown while notifying status listeners for AnimationController:
flutter: The provided ScrollController is currently attached to more than one ScrollPosition.
flutter: The Scrollbar requires a single ScrollPosition in order to be painted.
flutter: When the scrollbar is interactive, the associated ScrollController must only have one ScrollPosition
flutter: attached.The provided ScrollController must be unique to one ScrollView widget.
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 RawScrollbarState._debugCheckHasValidScrollPosition.<anonymous closure>
flutter: #1 RawScrollbarState._debugCheckHasValidScrollPosition
flutter: #2 RawScrollbarState._validateInteractions
flutter: #3 AnimationLocalStatusListenersMixin.notifyStatusListeners
flutter: #4 AnimationController._checkStatusChanged
flutter: #5 AnimationController._startSimulation
flutter: #6 AnimationController._animateToInternal
flutter: #7 AnimationController.forward
flutter: #8 RawScrollbarState._handleScrollNotification
flutter: #9 _NotificationElement.onNotification
flutter: #10 _NotificationNode.dispatchNotification
flutter: #11 _NotificationNode.dispatchNotification
flutter: #12 Element.dispatchNotification
flutter: #13 Notification.dispatch
flutter: #14 DragScrollActivity.dispatchScrollUpdateNotification
flutter: #15 ScrollPosition.didUpdateScrollPositionBy
flutter: #16 ScrollPosition.setPixels
flutter: #17 ScrollPositionWithSingleContext.setPixels
flutter: #18 ScrollPositionWithSingleContext.applyUserOffset
flutter: #19 ScrollDragController.update
flutter: #20 ScrollableState._handleDragUpdate
flutter: #21 DragGestureRecognizer._checkUpdate.<anonymous closure>
flutter: #22 GestureRecognizer.invokeCallback
flutter: #23 DragGestureRecognizer._checkUpdate
flutter: #24 DragGestureRecognizer.handleEvent
flutter: #25 PointerRouter._dispatch
flutter: #26 PointerRouter._dispatchEventToRoutes.<anonymous closure>
flutter: #27 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:617:13)
flutter: #28 PointerRouter._dispatchEventToRoutes
flutter: #29 PointerRouter.route
flutter: #30 GestureBinding.handleEvent
flutter: #31 GestureBinding.dispatchEvent
flutter: #32 RendererBinding.dispatchEvent
flutter: #33 GestureBinding._handlePointerEventImmediately
flutter: #34 GestureBinding.handlePointerEvent
flutter: #35 GestureBinding._flushPointerEventQueue
flutter: #36 GestureBinding._handlePointerDataPacket
flutter: #37 _invoke1 (dart:ui/hooks.dart:167:13)
flutter: #38 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:341:7)
flutter: #39 _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)
flutter:
flutter: The AnimationController notifying status listeners was:
flutter: AnimationController#17b14(▶ 0.000)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: The provided ScrollController is currently attached to more than one ScrollPosition.
flutter: Another exception was thrown: The provided ScrollController is currently attached to more than one ScrollPosition.
Reloaded 1 of 3347 libraries in 1 624ms (compile: 91 ms, reload: 494 ms, reassemble: 994 ms).
showCupertinoModalBottomSheet<String?>(
context: context,
// enableDrag: false,
// isDismissible: false,
barrierColor: Colors.transparent,
builder: (_) => ViewModelBuilder<ClientNotificationsViewModel>.reactive(
viewModelBuilder: () => ClientNotificationsViewModel(),
onModelReady: (viewModel) => viewModel.init(),
builder: (context, viewModel, child) {
return ModalBottomSheetContainerWithActions(
textDone: '',
title: 'Шаблоны',
onPressedDone: () {},
textCancel: t.actionClose,
loading: viewModel.isBusy,
contentPadding: const EdgeInsets.symmetric(
horizontal: kDefaultPadding,
),
onPressedCancel: () => Navigator.pop(context),
scrollController: ModalScrollController.of(context),
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
body: const [SmsWhatsAppNotificationsList(hasOnTap: true)],
actions: [
DefaultButton.small(
text: 'Создать шаблон',
width: ScreenUtils.of(context).screenWidth - kDefaultPadding * 2,
onPressed: () => showCupertinoModalBottomSheet<bool?>(
context: context,
barrierColor: Colors.transparent,
builder: (_) => const SmsWhatsAppNotificationBottomSheet(),
).then((value) {
if (value != null && value) {
viewModel.init();
}
}),
),
],
);
},
),
).then((value) => onChanged?.call(value));
SmsWhatsAppNotificationsList
return ListView.separated(
shrinkWrap: true,
padding: EdgeInsets.zero,
itemCount: viewModel.mailingList.length,
physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (_, __) => const SizedBox(height: kDefaultPadding),
itemBuilder: (_, i) {
final Mailing item = viewModel.mailingList[i];
return DefaultListItem(
cutDescription: false,
title: item.name ?? 'Нет названия',
description:
"${item.text} \n\nОтправлено: ${item.updatedAt != null ? BBDateUtils(item.updatedAt!).toDefault() : 'Нет'}",
onEditPressed: () => _buildEditPressed(context, viewModel, item),
onTap: hasOnTap
? () => Navigator.pop<String?>(context, item.text)
: () => _buildEditPressed(context, viewModel, item),
);
},
);
ModalBottomSheetContainerWithActions
CupertinoScrollbar(
controller: scrollController,
child: SingleChildScrollView(
physics: physics,
controller: scrollController,
child: Container(
padding: EdgeInsets.only(
top: !hasAppBar ? BBUiKitTheme.padding / 2 : 50,
bottom: hasActions
? ScreenUtils.of(context).hasBottomNotch
? ScreenUtils.of(context).bottomNotch
: BBUiKitTheme.padding
: 0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (hasTitle)
BBModalBottomSheetContentTitle(
title: title,
description: description,
titleCounter: titleCounter,
),
if (search != null)
SizedBox(
width: double.infinity,
child: StickyHeader(
header: Container(
padding: EdgeInsets.only(
top: 15,
left: BBUiKitTheme.padding,
right: BBUiKitTheme.padding,
bottom: BBUiKitTheme.padding / 2,
),
color: debug
? Colors.yellow[300]
: Theme.of(context).scaffoldBackgroundColor,
child: search,
),
content: Container(
padding: padding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: body,
),
),
),
),
if (search == null)
Container(
padding: padding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: body,
),
),
],
),
),
),
)