empty_widget.dart 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * @Author: XianKaiQun
  3. * @Date: 2020-09-29 11:21:53
  4. * @LastEditors : WuWei
  5. * @LastEditTime : 2022-01-19 10:46:44
  6. * @Description:
  7. */
  8. import 'package:flutter/material.dart';
  9. import 'package:flutter/widgets.dart';
  10. import 'package:wisdom_cli/src/assets.gen.dart';
  11. import 'package:wisdom_cli/wisdom_cli.dart';
  12. ///一个空提示
  13. class WEmptyWidget extends StatelessWidget {
  14. const WEmptyWidget({
  15. Key? key,
  16. this.text,
  17. this.imageWidth,
  18. this.margin,
  19. this.space,
  20. this.image,
  21. }) : super(key: key);
  22. final ImageProvider? image;
  23. final Widget? text;
  24. ///图标的大小 默认`200.pt`
  25. final double? imageWidth;
  26. ///默认`EdgeInsets.all(20.pt)`
  27. final EdgeInsetsGeometry? margin;
  28. ///较为朴素的空提示(图片没有背景)
  29. WEmptyWidget.plain({
  30. Key? key,
  31. this.text,
  32. double? imageWidth,
  33. this.margin,
  34. this.space,
  35. }) : image = AssetList.$emptyPlain_png_image,
  36. this.imageWidth = imageWidth ?? 83.pt;
  37. ///图片和文字的间隔
  38. final double? space;
  39. @override
  40. Widget build(BuildContext context) {
  41. return Wisdom.column(
  42. padding: margin ?? EdgeInsets.all(20.pt),
  43. alignment: Alignment.center,
  44. children: [
  45. WImage(
  46. image: image ?? AssetList.$empty_png_image,
  47. width: imageWidth ?? 200.pt,
  48. ),
  49. if (text != null) SizedBox(height: space ?? 18.pt),
  50. if (text != null)
  51. DefaultTextStyle(
  52. style: DefaultTextStyle.of(context).style.copyWith(
  53. fontSize: 14.pt,
  54. color: WTheme.of(context).colorScheme.minor,
  55. ),
  56. child: text!,
  57. )
  58. ],
  59. );
  60. }
  61. }