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

Sheet snaps to a wrong position after the keyboard is closed #22

Closed
fujidaiti opened this issue Feb 5, 2024 · 2 comments · Fixed by #27
Closed

Sheet snaps to a wrong position after the keyboard is closed #22

fujidaiti opened this issue Feb 5, 2024 · 2 comments · Fixed by #27
Assignees
Labels
bug Something isn't working
Milestone

Comments

@fujidaiti
Copy link
Owner

Steps to reproduce

Reproduction code
import 'package:flutter/material.dart';
import 'package:smooth_sheets/smooth_sheets.dart';

void main() {
  runApp(const DebugApp());
}

class DebugApp extends StatelessWidget {
  const DebugApp();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Builder(
            builder: (context) {
              return ElevatedButton(
                onPressed: () => showSheet(context),
                child: const Text('Show Sheet'),
              );
            },
          ),
        ),
      ),
    );
  }
}

void showSheet(BuildContext context) {
  Navigator.push(
    context,
    ModalSheetRoute(
      builder: (context) {
        return const SafeArea(
          bottom: false,
          child: DraggableSheet(
            minExtent: Extent.proportional(0.5),
            physics: SnappingSheetPhysics(
              snappingBehavior: SnapToNearest(
                snapTo: [
                  Extent.proportional(0.5),
                  Extent.proportional(1),
                ],
              ),
            ),
            child: SheetContentScaffold(
              body: SizedBox.expand(
                child: TextField(),
              ),
            ),
          ),
        );
      },
    ),
  );
}

Actual results

Video
RocketSim_Recording_iPhone_15_6.1_2024-02-05_21.29.39.mp4

Expected results

In the above example, the sheet position should be maintained before and after the keyboard is closed.

@fujidaiti fujidaiti added the bug Something isn't working label Feb 5, 2024
@fujidaiti fujidaiti self-assigned this Feb 5, 2024
@fujidaiti fujidaiti added this to the v0.3.0 milestone Feb 5, 2024
@appinteractive
Copy link

appinteractive commented Feb 9, 2024

Tried to implement something similar to Apple Maps and the Keyboard destroys the whole usability atm.

Everything else is smooth as f*ck. 🏆

Do you already have a vague time estimate?

@fujidaiti
Copy link
Owner Author

fujidaiti commented Feb 10, 2024

I'm already working on it!

branch/keyboard-issues 👀

@fujidaiti fujidaiti changed the title A sheet snaps to a wrong position after the keyboard is closed Sheet snaps to a wrong position after the keyboard is closed Feb 14, 2024
fujidaiti added a commit that referenced this issue Feb 14, 2024
Fixes #22. Unfortunately, there are still some problems related to the
keyboard (e.g. #14) that will be taken care of in a future PR.

Summary:

- Added `SheetExtent.settle`, which causes the sheet to settle into a
stationary position similar to the `goBallistic(0.0)`, but with a
constant (non zero) and relatively high velocity.
- Added `SheetActivity.didFinalizeDimensions`, which is called once in a
frame after all measurement processes for both the content and the
viewport size have been completed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants