util.dart 715 B

12345678910111213141516171819202122232425262728
  1. import 'package:flutter/material.dart';
  2. import 'package:dio/dio.dart';
  3. import '../showAlert.dart';
  4. bool isNotError(BuildContext context,json){
  5. print('-----------${json}----------');
  6. if(json is DioError){
  7. alertError(context, json.toString());
  8. return false;
  9. }else if( json.data['success']&& json.data['code']==1){
  10. return true;
  11. }else{
  12. alertError(context, json.data['msg']);
  13. return false;
  14. }
  15. }
  16. alertError(BuildContext context,String str){
  17. showDialog < Null > (
  18. context: context, //BuildContext对象
  19. barrierDismissible: false,
  20. builder: (BuildContext context) {
  21. return new LoadingDialog( //调用对话框
  22. text: str, childCallback: (val) {
  23. },
  24. );
  25. });
  26. }