fujidaiti / smooth_sheets

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

Using go_router .go() method to close a sheet don't seems to reset animation state #211

Open glemartret opened 1 month ago

glemartret commented 1 month ago

When I use .go() method from go router the current Sheet closes but the screen behind stays scaled down.

Quick exemple:

  1. currently on home page
  2. open a CupertinoSheet with go_router
  3. in the sheet, tap a button that does ".go(Home)"
  4. the sheet closes but the home page have black left, right and bottom borders

I'll complete this issue more precisely later. If anyone have some infos to help on this, I'll be thankful

fujidaiti commented 1 month ago

Hi @glemartret,

I tried the following code, but couldn't reproduce the problem. Can you fill in the missing part in the code to reproduce this issue?

Code ```dart 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(), ); }, ), ], ), ], ); 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 DraggableSheet( child: Container( color: Colors.white, height: 800, width: double.infinity, alignment: Alignment.center, child: TextButton( onPressed: () => context.go('/'), child: const Text('Close Sheet'), ), ), ); } } ```
fujidaiti commented 1 month ago

the sheet closes but the home page have black left, right and bottom borders

I guess this is because the transition animation is not performed when the modal sheet closes. (I don't know why, though)