custom_failure_widget.dart 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import 'package:flutter/material.dart';
  2. import 'package:widgets/ext/ex_widget.dart';
  3. /// Notify的Failure样式
  4. class CustomFailureWidget extends StatelessWidget {
  5. const CustomFailureWidget({
  6. Key? key,
  7. required this.msg,
  8. }) : super(key: key);
  9. final String msg;
  10. @override
  11. Widget build(BuildContext context) {
  12. return _buildBg(children: [
  13. const Icon(Icons.close, size: 38, color: Colors.white),
  14. Container(
  15. margin: const EdgeInsets.only(top: 15),
  16. child: Text(
  17. msg,
  18. style: const TextStyle(color: Colors.white, fontSize: 14),
  19. textAlign: TextAlign.center,
  20. ),
  21. ),
  22. ]);
  23. }
  24. Widget _buildBg({required List<Widget> children}) {
  25. return Container(
  26. padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20),
  27. decoration: BoxDecoration(
  28. color: const Color(0xcc000000), //不使用传递的背景色 制定自己的背景颜色
  29. borderRadius: BorderRadius.circular(10),
  30. ),
  31. child: Column(mainAxisSize: MainAxisSize.min, children: children),
  32. ).constrained(maxWidth: 250);
  33. }
  34. }