Jaime Blasco
Committed by GitHub

fix: update readme (#278)

  1 +<a href="https://jamesblasco.github.io/modal_bottom_sheet/#/"><img src="https://github.com/jamesblasco/modal_bottom_sheet/blob/screenshots/preview.png?raw=true"></a>
  2 +
  3 +# A modal bottom sheet for your Flutter app
  4 +
  5 +[![Awesome Flutter](https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square)](https://github.com/Solido/awesome-flutter)
  6 +[![Pub](https://img.shields.io/pub/v/modal_bottom_sheet.svg?logo=flutter&color=blue&style=flat-square)](https://pub.dev/packages/modal_bottom_sheet)
  7 +
  8 +Check the package [README](https://github.com/jamesblasco/modal_bottom_sheet/tree/main/modal_bottom_sheet) for more information
  9 +
  10 +### Sheet (Experimental)
  11 +
  12 +[Sheet](https://github.com/jamesblasco/modal_bottom_sheet/tree/main/sheet) is a new package that reimplements the modal bottom sheet behavior from scratch. It is expected to be easier to use, more performant, more stable, more customaziable and with more features. It is used in several released apps already. If you want to be part of it, I encourge you to give it a try and provide any feedback you might have :)
  13 +
  14 +
  15 +
  16 +
1 -# Sheet 1 +<img src="https://github.com/jamesblasco/modal_bottom_sheet/docs/assets/sheet.png?raw=true">
  2 +
  3 +
  4 +# Sheet Package
  5 +
  6 +[![Pub](https://img.shields.io/pub/v/sheet.svg?logo=flutter&color=blue&style=flat-square)](https://pub.dev/packages/sheet)
2 7
3 A fully customizable draggable bottom sheet for Flutter 8 A fully customizable draggable bottom sheet for Flutter
4 9
  10 +Sheet is a new package that intends to replace [modal_bottom_sheet](https://pub.dev/packages/modal_bottom_sheet) in a near future
  11 +
  12 +It allows to add a [Sheet] widget to any page or push a new [SheetRoute] to your navigator.
  13 +
5 ## Getting Started 14 ## Getting Started
6 15
  16 +Add the sheet package to your pubspec
  17 +
  18 +```sh
  19 +flutter pub add sheet
  20 +```
  21 +
  22 +Learn more about:
  23 + - Using [Sheet](modal_bottom_sheet/tree/main/sheet#sheet) to create bottom sheets inside your page
  24 + - Using [SheetRoute](modal_bottom_sheet/tree/main/sheet#sheetroute) or `SheetPage` to push a new modal bottom sheet route
  25 +
  26 +## Sheet
  27 +
7 ```dart 28 ```dart
8 Sheet( 29 Sheet(
9 initialExtent: 200, 30 initialExtent: 200,
@@ -11,7 +32,7 @@ Sheet( @@ -11,7 +32,7 @@ Sheet(
11 ) 32 )
12 ``` 33 ```
13 34
14 -You can add it above any widget 35 +You can add it above any other widget. Usually you might want to use a Stack for that
15 36
16 ```dart 37 ```dart
17 Stack( 38 Stack(
@@ -28,64 +49,76 @@ Stack( @@ -28,64 +49,76 @@ Stack(
28 49
29 The widget has several parameters that allow fully costumization of the sheet 50 The widget has several parameters that allow fully costumization of the sheet
30 51
31 -# Add an initial position 52 +#### Add an initial position
  53 +
  54 +Use `initialExtent` to set a initial offset from the bottom
  55 +
  56 +```dart
32 Sheet( 57 Sheet(
33 initialExtent: 200, 58 initialExtent: 200,
34 child: Container(color: Colors.blue[100]), 59 child: Container(color: Colors.blue[100]),
35 ) 60 )
  61 +```
  62 +
  63 +#### Clamp the sheet between a min and maximun values
36 64
  65 +You can set a `minExtent` and `maxExtent` to limit the position of the Sheet between those values
37 66
38 -# Clamp the sheet between a min and maximun values 67 +```dart
39 Sheet( 68 Sheet(
40 initialExtent: 200, 69 initialExtent: 200,
41 minExtent: 100, 70 minExtent: 100,
42 maxExtent: 400, 71 maxExtent: 400,
43 child: Container(color: Colors.blue[100]), 72 child: Container(color: Colors.blue[100]),
44 ) 73 )
  74 +```
45 75
46 76
47 -# Set a space value of interaction 77 +#### Allow to open the sheet when is fully hidden
48 78
49 -When the sheet is hidden you might wanna allow the user to drag up the  
50 -bottom sheet even if this one is no visible. You can define an area where  
51 -the interaction can be detected 79 +When the sheet is hidden you might wanna allow the user to drag up the bottom sheet even if this one is no visible. You can define an area where the interaction can be detected
52 80
  81 +```dart
53 Sheet( 82 Sheet(
54 initialExtent: 0, 83 initialExtent: 0,
55 minInteractionExtent: 20, 84 minInteractionExtent: 20,
56 child: Container(color: Colors.blue[100]), 85 child: Container(color: Colors.blue[100]),
57 ) 86 )
  87 +```
58 88
59 89
60 -# Fit modes 90 +#### Fit modes
61 91
62 -By default the sheet height will be the minimun between the max available height and the  
63 -one recommended by the child. 92 +By default the sheet height will be the minimun between the max available height and the one recommended by the child.
64 93
65 It is possible to force the sheet child to be the maxium size available by setting `SheetFit.expand` 94 It is possible to force the sheet child to be the maxium size available by setting `SheetFit.expand`
66 95
  96 +```dart
67 Sheet( 97 Sheet(
68 initialExtent: 200, 98 initialExtent: 200,
69 fit: SheetFit.expand, 99 fit: SheetFit.expand,
70 child: Container(color: Colors.blue[100]), 100 child: Container(color: Colors.blue[100]),
71 ) 101 )
  102 +```
72 103
73 -# Resizable 104 +#### Resizable
74 105
75 -By default the sheet has a fixed sized and it is translated according to the user scroll. 106 +By default the sheet has a fixed sized and it is vertically translated according to the user drag.
76 It is posible to make the sheet change the height of the child by setting `resize: true` 107 It is posible to make the sheet change the height of the child by setting `resize: true`
77 This will force the child to fit the available visual space. 108 This will force the child to fit the available visual space.
78 109
  110 +```dart
79 Sheet( 111 Sheet(
80 initialExtent: 200, 112 initialExtent: 200,
81 resizable:true 113 resizable:true
82 child: Container(color: Colors.blue[100]), 114 child: Container(color: Colors.blue[100]),
83 ) 115 )
  116 +```
84 117
85 -# Resizable with min size extent 118 +#### Resizable with min size extent
86 119
87 It is possible to set a min height for a resizable sheet. When the height reaches that min value, the sheet 120 It is possible to set a min height for a resizable sheet. When the height reaches that min value, the sheet
88 -will start translating instead of shrinking 121 +will start vertically translating instead of shrinking
89 122
90 ```dart 123 ```dart
91 Sheet( 124 Sheet(
@@ -96,7 +129,7 @@ Sheet( @@ -96,7 +129,7 @@ Sheet(
96 ``` 129 ```
97 130
98 131
99 -# Control the position of the sheet 132 +#### Control the position of the sheet
100 133
101 It is possible to pass a `SheetController` to control programatically the position of the sheet. 134 It is possible to pass a `SheetController` to control programatically the position of the sheet.
102 135
@@ -117,8 +150,7 @@ controller.animateTo(400, ...); @@ -117,8 +150,7 @@ controller.animateTo(400, ...);
117 controller.relativeAnimateTo(1, ...); // Value between 0 and 1 150 controller.relativeAnimateTo(1, ...); // Value between 0 and 1
118 ``` 151 ```
119 152
120 -The sheet controller also contains an animation value that can be used  
121 -to animate other parts of the ui in sync 153 +The sheet controller also contains an animation value that can be used to animate other parts of the ui in sync
122 154
123 ```dart 155 ```dart
124 AnimatedBuilder( 156 AnimatedBuilder(
@@ -129,5 +161,53 @@ AnimatedBuilder( @@ -129,5 +161,53 @@ AnimatedBuilder(
129 ); 161 );
130 ``` 162 ```
131 163
132 -The sheet controller also contains an animation value that can be used  
133 -to animate other parts of the ui in sync 164 +
  165 +## Sheet Route
  166 +
  167 +You can push a new modal bottom sheet route above your current page using `SheetRoute`
  168 +
  169 +
  170 +```dart
  171 +SheetRoute<void>(
  172 + builder: (BuildContext) => Container(),
  173 +)
  174 +```
  175 +
  176 +Or you can also use `SheetPage` with the Navigator 2.0
  177 +
  178 +```dart
  179 +Navigator(
  180 + pages: <Page<dynamic>>[
  181 + MaterialPage<bool>(
  182 + key: const ValueKey<String>('BooksListPage'),
  183 + child: BooksListScreen(
  184 + books: books,
  185 + onTapped: _handleBookTapped,
  186 + ),
  187 + ),
  188 + if (_selectedBook != null)
  189 + SheetPage<void>(
  190 + key: ValueKey<Book?>(_selectedBook),
  191 + child: BookDetailsScreen(book_selectedBook!),
  192 + barrierColor: Colors.black26,
  193 + )
  194 + ],
  195 +)
  196 +```
  197 +
  198 +An example using [GoRouter](https://pub.dev/packages/go_router) is available [here](https://github.com/jamesblasco/modal_bottom_sheet/blob/main/sheet/example/lib/examples/route/navigation/go_router.dart)
  199 +
  200 +
  201 +
  202 +#### Set the initial position
  203 +
  204 +Use `initialExtent` to set the initial position the bottom sheet will be dragged to:
  205 +
  206 +```dart
  207 +SheetRoute(
  208 + initialExtent: 200,
  209 + builder: (BuildContext) => Container(color: Colors.blue[100]),
  210 +)
  211 +```
  212 +
  213 +TBD