Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
modal_bottom_sheet
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Rafał Dziuryk
2020-08-14 21:56:20 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
166c259b0544c7c1813422e701ff5cfaa42a9b07
166c259b
1 parent
ab9e9af8
Fix PageView horizontal scroll
Add PageView Sample
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
2 deletions
example/lib/main.dart
example/lib/modals/modal_with_page_view.dart
lib/src/bottom_sheet.dart
example/lib/main.dart
View file @
166c259
...
...
@@ -13,6 +13,7 @@ import 'modals/modal_will_scope.dart';
import
'modals/modal_with_navigator.dart'
;
import
'modals/modal_with_nested_scroll.dart'
;
import
'modals/modal_with_scroll.dart'
;
import
'modals/modal_with_page_view.dart'
;
import
'examples/cupertino_share.dart'
;
...
...
@@ -240,6 +241,15 @@ class _MyHomePageState extends State<MyHomePage> {
NestedScrollModal
(
scrollController:
scrollController
),
)),
ListTile
(
title:
Text
(
'Modal with PageView'
),
onTap:
()
=>
showBarModalBottomSheet
(
expand:
true
,
context:
context
,
builder:
(
context
,
scrollController
)
=>
ModalWithPageView
(
scrollController:
scrollController
),
)),
SizedBox
(
height:
60
,
)
...
...
example/lib/modals/modal_with_page_view.dart
0 → 100644
View file @
166c259
import
'package:flutter/material.dart'
;
class
ModalWithPageView
extends
StatelessWidget
{
final
ScrollController
scrollController
;
const
ModalWithPageView
({
Key
key
,
this
.
scrollController
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
Material
(
child:
Scaffold
(
appBar:
AppBar
(
leading:
Container
(),
title:
Text
(
'Modal With Page View'
)),
body:
SafeArea
(
bottom:
false
,
child:
PageView
(
children:
List
.
generate
(
2
,
(
index
)
=>
ListView
(
shrinkWrap:
true
,
controller:
scrollController
,
children:
ListTile
.
divideTiles
(
context:
context
,
tiles:
List
.
generate
(
100
,
(
index
)
=>
ListTile
(
title:
Text
(
'Item'
),
)),
).
toList
(),
)),
),
),
),
);
}
}
...
...
lib/src/bottom_sheet.dart
View file @
166c259
...
...
@@ -259,6 +259,8 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
void
_handleScrollUpdate
(
ScrollNotification
notification
)
{
//Check if scrollController is used
if
(!
_scrollController
.
hasClients
)
return
;
//Check if there is more than 1 attached ScrollController e.g. swiping page in PageView
if
(
_scrollController
.
positions
.
length
>
1
)
return
;
final
scrollPosition
=
_scrollController
.
position
;
...
...
@@ -305,7 +307,7 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
if
(
dragDetails
!=
null
)
{
final
duration
=
_startTime
.
difference
(
DateTime
.
now
());
_velocityTracker
.
addPosition
(
duration
,
Offset
(
0
,
offset
));
_handleDragUpdate
(
dragDetails
.
primaryDelta
);
_handleDragUpdate
(
dragDetails
.
delta
.
dy
);
}
else
if
(
isDragging
)
{
final
velocity
=
_velocityTracker
.
getVelocity
().
pixelsPerSecond
.
dy
;
_velocityTracker
=
null
;
...
...
@@ -365,7 +367,7 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
delegate:
_CustomBottomSheetLayout
(
bounceAnimation
.
value
),
child:
GestureDetector
(
onVerticalDragUpdate:
(
details
)
{
_handleDragUpdate
(
details
.
primaryDelta
);
_handleDragUpdate
(
details
.
delta
.
dy
);
},
onVerticalDragEnd:
(
details
)
{
_handleDragEnd
(
details
.
primaryVelocity
);
...
...
Please
register
or
login
to post a comment