util.dart 869 B

1234567891011121314151617181920212223242526272829303132
  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 MyAlertDialog( //调用对话框
  22. text: str, childCallback: (val) {
  23. },
  24. );
  25. });
  26. }
  27. bool isChinaPhoneLegal(String str) {
  28. return new RegExp('^((13[0-9])|(15[^4])|(166)|(17[0-8])|(18[0-9])|(19[8-9])|(147,145))\\d{8}\$').hasMatch(str);
  29. }