surfstudio / flutter-bottom-sheet

Custom bottom sheet widget, that can resize by drag and then scroll. Made by Surf 🏄
Apache License 2.0
164 stars 42 forks source link

Error with showFlexibleBottomSheet - DraggableScrollableController is not attached to a sheet #57

Closed Skquark closed 2 years ago

Skquark commented 2 years ago

I'm getting this error all of a sudden after upgrading to the latest version:

The following assertion was thrown building LayoutBuilder:
DraggableScrollableController is not attached to a sheet. A DraggableScrollableController must be used in a DraggableScrollableSheet before any of its methods are called.
'package:flutter/src/widgets/draggable_scrollable_sheet.dart':
package:flutter/…/widgets/draggable_scrollable_sheet.dart:1
Failed assertion: line 170 pos 7: 'isAttached'

I tried a bunch of debug steps, looked into the code, doublechecked usage of showFlexibleBottomSheet, checked all issues, and can't figure it out. It was working fine before, I'd show my code, but it's basically the same as what you show in the examples. Any suggestions?

Skquark commented 2 years ago

I had to roll back to ^1.0.5 for the error to go away whenever I'd call skowFlexibleBottomSheet, even v2.0.0 was broken. Maybe it has to do with the latest Flutter update, I'm on the master channel which might have changed something with the DraggableScrollableController code. I don't know, but I'd be surprised if I'm the only person getting this bug.

airsend commented 2 years ago

Same error

treacks5 commented 2 years ago

Same 🐛

NatsuOnFire commented 2 years ago

Same error with new flutter 3.3.0 :

DraggableScrollableController is not attached to a sheet. A DraggableScrollableController must be used in a DraggableScrollableSheet before any of its methods are called.
'package:flutter/src/widgets/draggable_scrollable_sheet.dart':
Failed assertion: line 170 pos 7: 'isAttached'

see https://github.com/flutter/flutter/pull/100269

Darkildo commented 2 years ago

I fix the problem when insert check on isAttached. изображение

Skquark commented 2 years ago

Alright, that fix makes sense, good deal. Now it just needs to be patched in a new version release, then we'll be able to update to the corrected build. Will keep an eye out for the upgrade, would rather not create a fork to apply that change when it should be changed for everyone. Thanks!

aprzedecki commented 2 years ago

@Darkildo @Skquark can you create a PR with this fix ?

aprzedecki commented 2 years ago

Forget it, here is the PR https://github.com/surfstudio/flutter-bottom-sheet/pull/64

zaharovroman commented 2 years ago

The reason of issue: content of FlexibleBottomSheet uses size of it's controller when controller was not attached How was fixed: set default size for content of FlexibleBottomSheet with value of initHeight

 - currentExtent: _controller.size,
+ currentExtent: _controller.isAttached
+   ? _controller.size
+   : widget.initHeight,

Fixed on: https://github.com/surfstudio/flutter-bottom-sheet/pull/65

zaharovroman commented 2 years ago

https://user-images.githubusercontent.com/23340521/192293170-ed0948b3-7b15-4442-9fdc-d8e973c77536.mp4

KostyaLocal commented 1 year ago

Same bug. Is it fixed?