Open elliotkhd opened 1 year ago
I am also fancy this bug. I created a small reproducer.
🔗 https://github.com/martnst/modal_bottom_sheet_issue_345/
I spend some time looking at the framework's code, but could not yet figure out the root of the problem. For some reason, when scrolling beyond 100% (due to BouncingSheetPhysics
) the height of the sheet's child gets doubled.
However, through my digging session, I came up with this workaround for our client side code: We need to limit the height of our content, e.g. using a ConstrainedBox
.
Example:
class SomePage extends StatelessWidget {
const SomePage({
super.key,
});
@override
Widget build(BuildContext context) {
var colorScheme = Theme.of(context).colorScheme;
+ var appBar = AppBar(
+ backgroundColor: colorScheme.primary,
+ foregroundColor: colorScheme.onPrimary,
+ title: const Text("Some Paage"),
+ );
+
return Scaffold(
- appBar: AppBar(
- backgroundColor: colorScheme.primary,
- foregroundColor: colorScheme.onPrimary,
- title: const Text("Some Page"),
- ),
- body: Placeholder(
- color: colorScheme.primary,
+ appBar: appBar,
+ body: ConstrainedBox(
+ constraints: BoxConstraints(
+ maxHeight: MediaQuery.of(context).size.height - appBar.preferredSize.height - 20,
+ ),
+ child: Placeholder(
+ color: colorScheme.primary,
+ ),
),
);
}
}
In case this matters:
$ flutter --version
Flutter 3.10.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f468f3366c (4 months ago) • 2023-07-12 15:19:05 -0700
Engine • revision cdbeda788a
Tools • Dart 3.0.6 • DevTools 2.23.1
Facing the same issue. Will also dig a bit deeper whenever i have a more time.
Duplicate of #298
created a fork that includes PR #427 which fixes this issue plus some other issues. -> https://github.com/alexanderthiele/modal_bottom_sheet
https://user-images.githubusercontent.com/26217279/233890321-4b79fab0-7c3c-465c-a658-cabb4005420c.mp4
When the CupertinoSheetRoute page is a Column with a child wrapped by a Expanded, the child will disappeared when sliding up because of this issue