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 effect doesn't work when closing keyboard on non-fullscreen sheet #192

Closed
fujidaiti opened this issue Jul 11, 2024 · 1 comment · Fixed by #243
Closed

Snapping effect doesn't work when closing keyboard on non-fullscreen sheet #192

fujidaiti opened this issue Jul 11, 2024 · 1 comment · Fixed by #243
Assignees
Labels
bug Something isn't working P1
Milestone

Comments

@fujidaiti
Copy link
Owner

Thank you for your response and the suggestion to use SheetContentScaffold. However, the issue still persists, the sheet still partially moves up when the keyboard opens. I also noted your comment about avoiding nesting a sheet within a Scaffold, so I removed the scaffold from the root.

Here is the updated code I used:

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: SmoothSheetDemo(),
    );
  }
}

class SmoothSheetDemo extends StatefulWidget {
  const SmoothSheetDemo({super.key});

  @override
  _SmoothSheetDemoState createState() => _SmoothSheetDemoState();
}

class _SmoothSheetDemoState extends State<SmoothSheetDemo> {
  final SheetController _smoothSheetController = SheetController();

  @override
  Widget build(BuildContext context) {
    final List<double> snaps = [0.3, 0.5, 1.0];
    const minExtent = Extent.proportional(0.3);
    final extentSnaps = snaps.map((e) => Extent.proportional(e)).toList();
    final physics = SnappingSheetPhysics(
      snappingBehavior: SnapToNearest(
        snapTo: extentSnaps,
      ),
    );

    return SafeArea(
      child: Stack(
        children: [
          const Scaffold(
            body: Column(
              children: [
                TextField(),
                Expanded(
                  child: Placeholder(),
                )
              ],
            ),
            resizeToAvoidBottomInset: false,
          ),
          DraggableSheet(
            minExtent: minExtent,
            controller: _smoothSheetController,
            initialExtent: minExtent,
            physics: physics,
            child: SheetContentScaffold(
              body: buildContent(),
            ),
          ),
        ],
      ),
    );
  }

  Widget buildContent() {
    return Container(
      color: Colors.grey[900],
      child: Column(
        children: [
          const SizedBox(height: 16),
          const TextField(),
          const SizedBox(height: 16),
          Expanded(
            child: ListView(
              children: List.generate(
                100,
                (index) => Container(
                  margin: const EdgeInsets.all(4),
                  child: const FlutterLogo(),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Originally posted by @faizanje in #184 (comment)

@fujidaiti
Copy link
Owner Author

Screen_recording_20240628_221948.webm

Orignilally posted in #184 (comment)

@fujidaiti fujidaiti added this to the stable milestone Jul 11, 2024
@fujidaiti fujidaiti added the bug Something isn't working label Jul 11, 2024
@fujidaiti fujidaiti self-assigned this Jul 11, 2024
@fujidaiti fujidaiti changed the title Snapping effect doesn't work when closing keyboard Snapping effect doesn't work when closing keyboard on non-fullscreen sheet Jul 11, 2024
@fujidaiti fujidaiti added the P1 label Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant