-
-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
更新至1.0.3;修复使用CustomScrollView加载报错问题,修复部分视图在非SafeArea中偏移问题,添加CustomScr…
…ollView使用示例
- Loading branch information
xuelongqy
committed
Dec 21, 2018
1 parent
427667e
commit c6de284
Showing
16 changed files
with
377 additions
and
243 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
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
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import 'package:example/generated/translations.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_easyrefresh/easy_refresh.dart'; | ||
|
||
/// CustomScrollView示例页面 | ||
class SliverPage extends StatefulWidget { | ||
@override | ||
_SliverPageState createState() => _SliverPageState(); | ||
} | ||
|
||
class _SliverPageState extends State<SliverPage> { | ||
|
||
List<String> addStr=["1","2","3","4","5","6","7","8","9","0"]; | ||
List<String> str=["1","2","3","4","5","6","7","8","9","0"]; | ||
GlobalKey<EasyRefreshState> _easyRefreshKey = new GlobalKey<EasyRefreshState>(); | ||
GlobalKey<RefreshHeaderState> _headerKey = new GlobalKey<RefreshHeaderState>(); | ||
GlobalKey<RefreshFooterState> _footerKey = new GlobalKey<RefreshFooterState>(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: new EasyRefresh( | ||
key: _easyRefreshKey, | ||
refreshHeader: ClassicsHeader( | ||
key: _headerKey, | ||
refreshText: Translations.of(context).text("pullToRefresh"), | ||
refreshReadyText: Translations.of(context).text("releaseToRefresh"), | ||
refreshingText: Translations.of(context).text("refreshing") + "...", | ||
refreshedText: Translations.of(context).text("refreshed"), | ||
moreInfo: Translations.of(context).text("updateAt"), | ||
bgColor: Colors.orange, | ||
textColor: Colors.black, | ||
), | ||
refreshFooter: ClassicsFooter( | ||
key: _footerKey, | ||
loadHeight: 50.0, | ||
loadText: Translations.of(context).text("pushToLoad"), | ||
loadReadyText: Translations.of(context).text("releaseToLoad"), | ||
loadingText: Translations.of(context).text("loading"), | ||
loadedText: Translations.of(context).text("loaded"), | ||
noMoreText: Translations.of(context).text("noMore"), | ||
moreInfo: Translations.of(context).text("updateAt"), | ||
bgColor: Colors.orange, | ||
textColor: Colors.black, | ||
), | ||
onRefresh: () async{ | ||
await new Future.delayed(const Duration(seconds: 1), () { | ||
setState(() { | ||
str.clear(); | ||
str.addAll(addStr); | ||
}); | ||
}); | ||
}, | ||
loadMore: () async { | ||
await new Future.delayed(const Duration(seconds: 1), () { | ||
if (str.length < 20) { | ||
setState(() { | ||
str.addAll(addStr); | ||
}); | ||
} | ||
}); | ||
}, | ||
child: CustomScrollView( | ||
// 手动维护semanticChildCount,用于判断是否没有更多数据 | ||
semanticChildCount: str.length, | ||
slivers: <Widget>[ | ||
SliverAppBar( | ||
floating: false, | ||
pinned: true, | ||
expandedHeight: 180.0, | ||
flexibleSpace: FlexibleSpaceBar( | ||
title: Text("CustomScrollView"), | ||
), | ||
), | ||
SliverPadding( | ||
padding: EdgeInsets.all(0.0), | ||
sliver: SliverFixedExtentList( | ||
itemExtent: 70.0, | ||
delegate: SliverChildBuilderDelegate((context, index){ | ||
return new Container( | ||
height: 70.0, | ||
child: Card( | ||
child: new Center( | ||
child: new Text(str[index],style: new TextStyle(fontSize: 18.0),), | ||
), | ||
) | ||
); | ||
}, | ||
childCount: str.length, | ||
) | ||
), | ||
) | ||
], | ||
) | ||
) | ||
); | ||
} | ||
} |
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
Oops, something went wrong.