smooth_sheets 0.9.3 copy "smooth_sheets: ^0.9.3" to clipboard
smooth_sheets: ^0.9.3 copied to clipboard

Sheet widgets with smooth motion and great flexibility. Also supports nested navigation in both imperative and declarative ways.

smooth_sheets #

GitHub Repo stars GitHub last commit (branch) Pub Version Pub Likes Pub Points Pub Popularity

smooth_sheets offers modal and persistent sheet widgets for Flutter apps. The key features are:

  • Smooth motion: The sheets respond to user interaction with smooth, graceful motion.
  • Highly flexible: Not restricted to a specific design. Both modal and persistent styles are supp/orted, as well as scrollable and non-scrollable widgets.
  • Supports nested navigation: A sheet is able to have multiple pages and to navigate between the pages with motion animation for transitions.
  • Works with imperative & declarative Navigator API: No special navigation mechanism is required. The traditional ways such as Navigator.push is supported and it works with Navigator 2.0 packages like go_route as well.
  • iOS flavor: The modal sheets in the style of iOS 15 are supported.

CAUTION🚨

This library is currently in the experimental stage. The API may undergo changes without prior notice. For documentation of the latest published version, please visit the package site on pub.dev.


Migration guide #

See here for older versions.


Showcases #

AI Playlist Generator

An AI assistant that helps create a music playlist based on the user's preferences. See the cookbook for more details.

Key components:

  • NavigationSheet
  • ModalSheetPage
  • DraggableNavigationSheetPage
  • ScrollableNavigationSheetPage
  • SheetDismissible

Safari app

A practical example of ios-style modal sheets. See the cookbook for more details.

Key components:

  • CupertinoStackedTransition
  • CupertinoModalSheetRoute

Airbnb mobile app clone

A partial clone of the Airbnb mobile app. The user can drag the house list down to reveal the map behind it. See the cookbook for more details.

Key components:

  • ScrollableSheet
  • SheetPhysics
  • SheetController
  • ExtentDrivenAnimation

Todo List

A simple Todo app that shows how a sheet handles the on-screen keyboard. See the cookbook for more details.

Used components:

  • ScrollableSheet
  • SheetContentScaffold
  • SheetKeyboardDismissBehavior
  • SheetDismissible
  • StickyBottomBarVisibility

Why use this? #

There are few packages on pub.dev that supports nested navigation with motion animation for page transitions. One of the great choices for this usecase is wolt_modal_sheet, which this package is inspired by. Although smooth_sheet has similar features with wolt_modal_sheet, it does not intended to be a replacement of that package. Here is some differences between those 2 packages:

wolt_modal_sheet smooth_sheets
Design Based on Wolt's design guideline Not restricted to a specific design, fully customizable
Navigation mechanism Manage the page index in ValueNotifier Works with built-in Navigator API (both of imperative and declarative)
Scrollable content Supported Supported
Persistent sheets Not supported Supported
Screen size adaptation The sheet appears as a dialog on large screens Not supported

Usage #

Several resources are available for learning the functionalities of this package.

  • Tutorials: See cookbook/lib/tutorial/ to learn the basic usage of the core components.
  • Showcases: More practical examples are available in cookbook/lib/showcase/.
  • Documentation: WORK IN PROGRESS! Please see the source code for a while.

Ingredients #

This section provides descriptions for each core component and links to related resources for further learning.


Extent #

Extent represents the visible height of the sheet. It is used in a variety of situations, for example, to specify how much area of a sheet is initially visible at first build, or to limit the range of sheet dragging.


DraggableSheet #

A sheet that can be dragged. The height will be equal to the content. The behavior of the sheet when over-dragged or under-dragged is determined by SheetPhysics. Note that this widget does not work with scrollable widgets. Instead, use ScrollableSheet for this usecase.

See also:


ScrollableSheet #

A sheet that is similar to DraggableSheet, but specifically designed to be integrated with scrollable widgets. It will begin to be dragged when the content is over-scrolled or under-scrolled.

See also:


A sheet that is able to have multiple pages and performs graceful motion animation when page transitions. It supports both of imperative Navigator API such as Navigator.push, and declarative API (Navigator 2.0).

See also:


ModalSheets #

A sheet can be displayed as a modal sheet using ModalSheetRoute for imperative navigation, or ModalSheetPage for declarative navigation. To enable the swipe-to-dismiss action, which allows the user to dismiss the sheet by a swiping-down gesture, set swipeDismissible to true.

Furthermore, the modal sheets in the style of iOS 15 are also supported. For imperative navigation, use CupertinoModalSheetRoute, and for declarative navigation, use CupertinoModalSheetPage, respectively.

See also:


SheetPhysics #

A physics determines how the sheet will behave when over-dragged or under-dragged, or when the user stops dragging. There are 3 predefined physics:

  • ClampingSheetPhysics: Prevents the sheet from reaching beyond the content bounds.
  • BouncingSheetPhysics: Allows the sheet to go beyond the content bounds, but then bounce the sheet back to the edge of those bounds. Use BouncingBehavior and its subclasses to tweak the bouncing behavior.
  • SnappingSheetPhysics: Automatically snaps the sheet to a certain extent when the user stops dragging.

These physics can be combined to create more complex behavior (e.g. bouncing behavior + snapping behavior).

See also:


SheetController #

Like ScrollController for scrollable widget, the SheetController can be used to animate or observe the extent of a sheet.

See also:


SheetContentScaffold #

A special kind of Scaffold designed for use in a sheet. It has slots for an app bar and a bottom bar, similar to Scaffold. However, it differs in that its height reduces to fit the content widget.

See also:


SheetDraggable #

SheetDraggable enables its child widget to act as a drag handle for the sheet. Typically, you will want to use this widget when placing non-scrollable widget(s) in a ScrollableSheet, since it only works with scrollable widgets, so you can't drag the sheet by touching a non-scrollable area. Try removing SheetDraggable and you will see that the drag handle doesn't work as it should. Note that SheetDraggable is not needed when using DraggableSheet since it implicitly wraps the child widget with SheetDraggable.

See also:


ExtentDrivenAnimation #

It is easy to create sheet extent driven animations by using ExtentDrivenAnimation, a special kind of Animation whose value changes from 0 to 1 as the sheet extent changes from 'startExtent' to 'endExtent'.

See also:

  • extent_driven_animation for basic usage.
  • airbnb_mobile_app.dart, which show how ExtentDrivenAnimation can be used to hide the bottom navigation bar and a FAB when the sheet is dragged down, and to show them when the sheet is dragged up again.

SheetNotification #

A sheet dispatches a SheetNotification when its extent changes. This can be used to observe the extent of a descendant sheet from an ancestor widget.

NotificationListener<SheetNotification>(
  onNotification: (notification) {
    debugPrint('${notification.metrics}');
    return false;
  },
  child: DraggableSheet(...),
),

See also:


SheetKeyboardDismissBehavior #


SheetKeyboardDismissBehavior determines when the sheet should dismiss the on-screen keyboard. This feature is similar to ScrollViewKeyboardDismissBehavior for scrollable widgets.

Although it is easy to create custom behaviors by implementing SheetKeyboardDismissBehavior interface, there are 3 types of predefined behaviors for convenience.

See also:


Questions #

If you have any questions, feel free to ask them on the discussions page.


Contributing #

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request


287
likes
0
pub points
93%
popularity

Publisher

verified publishernorelease.dev

Sheet widgets with smooth motion and great flexibility. Also supports nested navigation in both imperative and declarative ways.

Repository (GitHub)
View/report issues

Topics

#ui #widget #bottom-sheet

License

unknown (license)

Dependencies

collection, flutter, meta

More

Packages that depend on smooth_sheets