Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapping behavior broken when initialSnap is not 1.0 #36

Open
amrahmed242 opened this issue Aug 9, 2024 · 0 comments
Open

Snapping behavior broken when initialSnap is not 1.0 #36

amrahmed242 opened this issue Aug 9, 2024 · 0 comments

Comments

@amrahmed242
Copy link

Description

The snapping behavior becomes inconsistent and unreliable when using the SlidingSheet widget with an initialSnap value other than 1.0.

initialSnap: 1.0 initialSnap: 0.3 (or any)

Steps to Reproduce:

  1. Create a SlidingSheet widget with two or more snap positions defined.
  2. Set the initialSnap parameter to a value other than 1.0 (e.g., 0.5).
  3. Run the app and try to drag the sheet to different snap positions.
  4. see the snapping behaviour is now broken.

Expected Behavior:

The sheet should snap correctly to the defined snap positions regardless of the initialSnap value.

Actual Behavior:

The sheet fails to snap properly to the defined positions when the initialSnap value is not 1.0. It may get stuck between positions or fail to reach certain snap points.

Additional Information:

  • Flutter version: 3.13.9
  • wtf_sliding_sheet: 1.1.2
Sheet setup
SlidingSheet(
                controller: controller,
                openDuration: const Duration(milliseconds: 500),
                snapSpec: SnapSpec(
                  snap: true,
                  initialSnap: .3,
                  positioning: SnapPositioning.relativeToSheetHeight,
                  snappings: <double>[.3, 1],
                ),
                color: Colors.white70,
                elevation: 10,
                cornerRadius: 16,
                cornerRadiusOnFullscreen: 16.0,
                closeOnBackdropTap: true,
                closeOnBackButtonPressed: true,
                addTopViewPaddingOnFullscreen: false,
                isBackdropInteractable: false,
                parallaxSpec: const ParallaxSpec(
                  enabled: true,
                  amount: 0.35,
                  endExtent: 0.5,
                ),
                liftOnScrollHeaderElevation: 12.0,
                liftOnScrollFooterElevation: 0.0,
                builder: (BuildContext context, SheetState state) {
                  return Container(
                    height: 900,
                    child: Center(
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.spaceAround,
                        children: const <Widget>[
                          Text('This is the content of the sheet'),
                          Text('This is the content of the sheet'),
                          Text('This is the content of the sheet'),
                          Text('This is the content of the sheet'),
                        ],
                      ),
                    ),
                  );
                },
              )
Full Code sample
import 'package:flutter/material.dart';
import 'package:wtf_sliding_sheet/wtf_sliding_sheet.dart';

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);
  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final SheetController controller = SheetController();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(children: <Widget>[
        Container(
          color: Colors.blueGrey,
          child: Center(
            child: Text('Home Widget'),
          ),
        ),
        Align(
            alignment: Alignment.bottomCenter,
            child: SafeArea(
              child: SlidingSheet(
                controller: controller,
                openDuration: const Duration(milliseconds: 500),
                snapSpec: SnapSpec(
                  snap: true,
                  initialSnap: .3,
                  positioning: SnapPositioning.relativeToSheetHeight,
                  snappings: <double>[.3, 1],
                ),
                color: Colors.white70,
                elevation: 10,
                cornerRadius: 16,
                cornerRadiusOnFullscreen: 16.0,
                closeOnBackdropTap: true,
                closeOnBackButtonPressed: true,
                addTopViewPaddingOnFullscreen: false,
                isBackdropInteractable: false,
                parallaxSpec: const ParallaxSpec(
                  enabled: true,
                  amount: 0.35,
                  endExtent: 0.5,
                ),
                liftOnScrollHeaderElevation: 12.0,
                liftOnScrollFooterElevation: 0.0,
                builder: (BuildContext context, SheetState state) {
                  return Container(
                    height: 900,
                    child: Center(
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.spaceAround,
                        children: const <Widget>[
                          Text('This is the content of the sheet'),
                          Text('This is the content of the sheet'),
                          Text('This is the content of the sheet'),
                          Text('This is the content of the sheet'),
                        ],
                      ),
                    ),
                  );
                },
              ),
            ))
      ]),
    );
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant