forked from peng8350/flutter_pulltorefresh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add DraggableScrollableSheet+Loadmore example
- Loading branch information
Showing
7 changed files
with
117 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
example/lib/ui/example/otherwidget/draggable_bottomsheet_loadmore.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Author: Jpeng | ||
* Email: [email protected] | ||
* Time: 2019-07-03 17:24 | ||
*/ | ||
|
||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import '../../Item.dart'; | ||
import 'package:pull_to_refresh/pull_to_refresh.dart'; | ||
|
||
/* | ||
notice that,If your combine with DraggableScrollSheet with SmartRefresher, | ||
It not support enablePullDown,only support enablePullUp = true. | ||
the second, the example has StatefulBuilder,just not setState(),it will never rebuild scrollSheet | ||
*/ | ||
class DraggableLoadingBottomSheet extends StatefulWidget { | ||
@override | ||
State<StatefulWidget> createState() { | ||
// TODO: implement createState | ||
return _DraggableLoadingBottomSheetState(); | ||
} | ||
} | ||
|
||
class _DraggableLoadingBottomSheetState | ||
extends State<DraggableLoadingBottomSheet> { | ||
RefreshController _controller = RefreshController(); | ||
|
||
List<String> items = []; | ||
|
||
@override | ||
void initState() { | ||
// TODO: implement initState | ||
super.initState(); | ||
for (int i = 0; i < 15; i++) items.add("数据"); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
// TODO: implement build | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('DraggableScrollableSheet'), | ||
), | ||
body: Container( | ||
child: RaisedButton( | ||
onPressed: () { | ||
showModalBottomSheet( | ||
backgroundColor: Colors.transparent, | ||
context: context, | ||
builder: (c) { | ||
return DraggableScrollableSheet( | ||
initialChildSize: 1.0, | ||
maxChildSize: 1.0, | ||
minChildSize: 0.5, | ||
builder: (BuildContext context, | ||
ScrollController scrollController) { | ||
return Container( | ||
color: Colors.blue[100], | ||
child: StatefulBuilder( | ||
builder: (BuildContext context2, setter) { | ||
return SmartRefresher( | ||
child: ListView.separated( | ||
controller: scrollController, | ||
separatorBuilder: (c, i) => Divider(), | ||
itemBuilder: (_, e) => Container( | ||
child: | ||
Center(child: Text("菜单" + e.toString())), | ||
height: 40.0, | ||
), | ||
physics: ClampingScrollPhysics(), | ||
itemCount: items.length, | ||
), | ||
controller: _controller, | ||
onLoading: () async { | ||
await Future.delayed( | ||
Duration(milliseconds: 1000)); | ||
_controller.loadComplete(); | ||
for (int i = 0; i < 15; i++) { | ||
items.add("1"); | ||
} | ||
|
||
setter(() {}); | ||
}, | ||
enablePullUp: true, | ||
enablePullDown: false, | ||
); | ||
}, | ||
), | ||
); | ||
}, | ||
); | ||
}); | ||
}, | ||
child: Text("点击打开滑动BottomSheet"), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters