custom_error_widget.dart 991 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import 'package:eitc_erm_dental_flutter/funcs.dart';
  2. import 'package:eitc_erm_dental_flutter/http/api_exception.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. class CustomErrorWidget extends StatelessWidget {
  6. final Object error;
  7. const CustomErrorWidget({super.key, required this.error});
  8. @override
  9. Widget build(BuildContext context) {
  10. return Column(mainAxisSize: MainAxisSize.min, children: [
  11. Icon(
  12. Icons.error_outline,
  13. size: 40.r,
  14. color: Colors.red,
  15. ),
  16. SizedBox(
  17. height: 10.h,
  18. ),
  19. _getText()
  20. ]);
  21. }
  22. Widget _getText() {
  23. String str;
  24. if (error is ApiException) {
  25. str = (error as ApiException).message ?? "";
  26. } else {
  27. str = "$error";
  28. }
  29. if (str.isEmpty) {
  30. str = getS().unknownException;
  31. }
  32. return Text(
  33. str,
  34. textAlign: TextAlign.center,
  35. style: TextStyle(color: Colors.red),
  36. );
  37. }
  38. }