fujidaiti / smooth_sheets

Sheet widgets with smooth motion and great flexibility.
https://pub.dev/packages/smooth_sheets
MIT License
208 stars 20 forks source link

Modal sheet jerks when swipe to dismiss #250

Open glemartret opened 1 week ago

glemartret commented 1 week ago

Using go_router ^14 to open the sheet I get a strange behavior that I don't get with go_router 13 When swipe to dismiss a CupertinoSheet the sheet jerks during the movement

fujidaiti commented 5 days ago

Hi @glemartret,

I could see the reported behavior in the Todo list example, but not in the other modal sheet examples, such as cupertino_modal_sheet.dart and imperative_modal_sheet.dart. I also noticed that in the Todo list app, the sheet jerks even with go_router v12.

https://github.com/user-attachments/assets/df449bcc-e8c4-4332-9132-0646479e1b63

Could you provide an executable, minimal reproduction code?

glemartret commented 3 hours ago

Hey @fujidaiti, I've been able to narrow down this issue to a line added by go_router_builder in my case

Code ``` import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:smooth_sheets/smooth_sheets.dart'; void main() { runApp(const _DeclarativeModalSheetExample()); } final _router = GoRouter( routes: [ GoRoute( path: '/', builder: (context, state) { return const _ExampleHome(); }, routes: [ GoRoute( path: 'modal-sheet', pageBuilder: (context, state) { return CupertinoModalSheetPage( key: state.pageKey, swipeDismissible: true, child: const _ExampleSheet(), ); }, // INFO: This is added to route by go_router_builder in my case <===================== onExit: (context, state) => true, ), ], ), ], ); class _DeclarativeModalSheetExample extends StatelessWidget { const _DeclarativeModalSheetExample(); @override Widget build(BuildContext context) { return MaterialApp.router(routerConfig: _router); } } class _ExampleHome extends StatelessWidget { const _ExampleHome(); @override Widget build(BuildContext context) { return CupertinoStackedTransition( child: Scaffold( body: Center( child: ElevatedButton( onPressed: () => context.go('/modal-sheet'), child: const Text('Show Modal Sheet'), ), ), ), ); } } class _ExampleSheet extends StatelessWidget { const _ExampleSheet(); @override Widget build(BuildContext context) { return ScrollableSheet( physics: const ClampingSheetPhysics(), child: SheetContentScaffold( body: SingleChildScrollView( child: Container( color: Colors.white, height: 800, width: double.infinity, alignment: Alignment.center, child: TextButton( onPressed: () async { context.go('/'); }, child: const Text('Close Sheet'), ), ), ), ), ); } } ```