import 'package:flutter/material.dart';
import 'package:dio/dio.dart';
import '../showAlert.dart';
bool isNotError(BuildContext context,json){
  //print('-----------'+json+'----------');
  if(json is DioError){
    alertError(context, json.toString());
    return false;
  }else if( json.data['success']&& json.data['code']==1){
    return true;
  }else{
    alertError(context, json.data['msg']);
    return false;
  }
}

alertError(BuildContext context,String str){
  showDialog < Null > (
  context: context, //BuildContext对象
  barrierDismissible: false,
  builder: (BuildContext context) {
    return MyAlertDialog( //调用对话框
      text: str, childCallback: (val) {
        
      },
    );
  });
}

bool isChinaPhoneLegal(String str) {
  return new RegExp('^((13[0-9])|(15[^4])|(166)|(17[0-8])|(18[0-9])|(19[8-9])|(147,145))\\d{8}\$').hasMatch(str);
}
