indicator_factory.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/widgets.dart';
  3. import 'package:pull_to_refresh/pull_to_refresh.dart';
  4. /*
  5. * Author: Jpeng
  6. * Email: peng8350@gmail.com
  7. * Time: 2018/5/30 上午10:25
  8. */
  9. Widget buildDefaultHeader(BuildContext context, int mode) {
  10. return new ClassicIndicator(
  11. failedText: '刷新失败!',
  12. completeText: '刷新完成!',
  13. releaseText: '释放可以刷新',
  14. idleText: '下拉刷新哦!',
  15. failedIcon: new Icon(Icons.clear, color: Colors.black),
  16. completeIcon: new Icon(Icons.done, color: Colors.black),
  17. idleIcon: new Icon(Icons.arrow_downward, color: Colors.black),
  18. releaseIcon: new Icon(Icons.arrow_upward, color: Colors.black),
  19. refreshingText: '正在刷新...',
  20. textStyle: Theme.of(context).textTheme.body2,
  21. mode: mode,
  22. );
  23. }
  24. Widget buildDefaultFooter(BuildContext context, int mode,
  25. [Function requestLoad]) {
  26. if (mode == RefreshStatus.failed || mode == RefreshStatus.idle) {
  27. return new InkWell(
  28. child: new ClassicIndicator(
  29. mode: mode,
  30. idleIcon: new Icon(Icons.arrow_upward, color: Colors.black),
  31. textStyle: Theme.of(context).textTheme.body2,
  32. refreshingText: '正在加载中...',
  33. idleText: '上拉加载',
  34. failedText: '网络异常',
  35. noDataText: '没有更多数据'),
  36. onTap: requestLoad,
  37. );
  38. } else
  39. return new ClassicIndicator(
  40. mode: mode,
  41. idleIcon: new Icon(Icons.arrow_upward, color: Colors.black),
  42. textStyle: Theme.of(context).textTheme.body2,
  43. refreshingText: '正在加载中...',
  44. idleText: '上拉加载',
  45. failedText: '网络异常',
  46. noDataText: '没有更多数据');
  47. }