error.dart 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. class RequestErrorWidget extends StatelessWidget {
  4. final VoidCallback callback;
  5. final String msg;
  6. final String assets;
  7. final String action;
  8. static const String ASSETS_NO_NETWORK = "emptypage-image-nonetwork.png";
  9. static const String ASSETS_NO_COMMENT = "emptypage-image-nocomment.png";
  10. static const String ASSETS_NO_INVITATION = "emptypage-image-noinvitation.png";
  11. static const String ASSETS_NO_MOTION = "emptypage-image-nomotion.png";
  12. static const String ASSETS_NO_RANK = "emptypage-image-noattainment.png";
  13. RequestErrorWidget(this.callback, {this.msg = "网络出错啦,请点击按钮重新加载", this.assets = ASSETS_NO_NETWORK, this.action = "重新加载"});
  14. @override
  15. Widget build(BuildContext context) {
  16. return Column(
  17. mainAxisSize: MainAxisSize.min,
  18. children: <Widget>[
  19. Padding(
  20. padding: const EdgeInsets.fromLTRB(0, 50, 0, 0),
  21. child: Image.asset("lib/assets/img/${this.assets}"),
  22. ),
  23. Padding(
  24. padding: const EdgeInsets.fromLTRB(0, 12, 0, 12),
  25. child: Text(
  26. this.msg,
  27. style: Theme.of(context).textTheme.bodyText2,
  28. ),
  29. ),
  30. if (callback != null)
  31. Padding(
  32. padding: const EdgeInsets.all(16.0),
  33. child: OutlineButton(
  34. child: Text(
  35. "$action",
  36. style: TextStyle(fontSize: 14.0),
  37. ),
  38. clipBehavior: Clip.hardEdge,
  39. shape: StadiumBorder(),
  40. textColor: Color(0xff666666),
  41. color: Color(0xff666666),
  42. highlightedBorderColor: Theme.of(context).accentColor,
  43. highlightColor: Theme.of(context).accentColor,
  44. onPressed: callback,
  45. ),
  46. ),
  47. SizedBox(
  48. height: 100,
  49. )
  50. ],
  51. );
  52. }
  53. }