Open vongrad opened 11 months ago
Reproducible using the code sample and steps provided above.
I've noticed this issue as well using Flutter 3.24.1 and a Pixel 8a with Impeller enabled. On my end, it's random. 2 times out of 3 it works as expected, the remaining time the modal fails to close, leaving the UI in a confusing state. Here's some of my code in case it helps:
showAbout(BuildContext context) {
// presentModally(context: context, content: const WelcomePamphlet());
showModalBottomSheet(
useSafeArea: true,
context: context,
isScrollControlled: true,
showDragHandle: false,
isDismissible: true,
enableDrag: true,
sheetAnimationStyle: AnimationStyle(curve: Curves.linear),
builder: (context) => DraggableScrollableSheet(
expand: false,
snap: true,
initialChildSize: 0.95,
maxChildSize: 0.95,
minChildSize: 0,
shouldCloseOnMinExtent: true,
builder: (context, scrollController) => WelcomePamphlet(
scrollController: scrollController,
),
),
);
}
class WelcomePamphlet extends StatelessWidget {
ScrollController scrollController;
WelcomePamphlet({super.key, required this.scrollController});
@override
Widget build(BuildContext context) {
return CustomScrollView(
controller: scrollController,
slivers: [
SliverAppBar(
title: Text("My Title"),
floating: true,
snap: true,
pinned: true,
),
SliverList(
delegate: SliverChildListDelegate(
[
// Content
],
),
)
],
);
}
}
This issue prevents makes DraggableScrollableSheet
unreliable to the point where I cannot recommend using it if the sheet needs to be dismissed.
Any update on this?
Any updates?
Steps to reproduce
_DraggableSheetExtent._currentSize
not hitting value of0.0
, but instead getting stuck on extremely small values like1.3877787807814457e-17
Expected results
The modal sheet is dismissed once the ballistic simulation completes.
Actual results
The modal sheet is visible once the ballistic simulation completes. This does not happen always, but I can reproduce it about 1/4 of the time.
I believe the issue is within
_DraggableScrollableSheetScrollPosition
, specifically ingoBallistic
function. When using theextent.snap
, we use_SnappingSimulation
, which seems to be working fine. However a few lines further, atick
function is defined, where adelta
is added to the currentextent
value:I believe we could fix it in
else if (ballisticController.isCompleted)
by checking if theextent
value is very close to zero (x <= 0.01) and if so, rounding it to 0.0. I however do not think this would be the right fix and we should rather see why we do not hit exact 0. This could perhaps be caused bypixelsToSize
where theavailablePixels
are off by 1 or so.Code sample
Code sample
```dart import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const MyHomePage(), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key}); @override StateScreenshots or Video
Screenshots / Video demonstration
[Upload media here]https://github.com/flutter/flutter/assets/3223913/835b6863-59c2-4ed3-91a8-e60fc7f84e19
Logs
These are the extent values obtained from DraggableScrollableNotification
``` NotificationListenerFlutter Doctor output
Doctor output
```console [✓] Flutter (Channel stable, 3.16.0, on macOS 14.2.1 23C71 darwin-arm64, locale en-DK) • Flutter version 3.16.0 on channel stable at /Users/vongrad/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision db7ef5bf9f (6 weeks ago), 2023-11-15 11:25:44 -0800 • Engine revision 74d16627b9 • Dart version 3.2.0 • DevTools version 2.28.2 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/vongrad/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = /Users/vongrad/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15C65 • CocoaPods version 1.14.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2023.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) [✓] Connected device (4 available) • vongrad (mobile) • 00008120-001814C13683C01E • ios • iOS 17.1.2 21B101 • iPhone 15 Pro (mobile) • 3ED33087-E9F9-44EA-B99B-EAF7641B486E • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.2.1 23C71 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 120.0.6099.129 [✓] Network resources • All expected network resources are available. • No issues found! ```