添加头像上传功能

This commit is contained in:
魏少阳 2024-04-10 13:36:00 +08:00
parent 66c4d489b5
commit 917f1f1489
16 changed files with 155 additions and 126 deletions

View File

@ -399,15 +399,14 @@ class BlueManage {
} }
// await bluetoothConnectDevice!.connect(); // await bluetoothConnectDevice!.connect();
Get.log("5555555:回调状态:$bluetoothConnectionState");
if (bluetoothConnectionState == BluetoothConnectionState.connected) { if (bluetoothConnectionState == BluetoothConnectionState.connected) {
try { try {
bluetoothConnectDevice!.discoverServices().then((services) { bluetoothConnectDevice!.discoverServices().then((services) {
for (BluetoothService service in services) { for (BluetoothService service in services) {
// Get.log("11111service.remoteId:${service.remoteId}" Get.log("11111service.remoteId:${service.remoteId}"
// " service.uuid:${service.uuid}" " service.uuid:${service.uuid}"
// " service.characteristics:${service.characteristics}" " service.characteristics:${service.characteristics}"
// " service.includedServices:${service.includedServices}"); " service.includedServices:${service.includedServices}");
if (service.uuid == _serviceIdConnect) { if (service.uuid == _serviceIdConnect) {
for (BluetoothCharacteristic characteristic in service.characteristics) { for (BluetoothCharacteristic characteristic in service.characteristics) {
// Get.log("22222characteristic.remoteId:${characteristic.remoteId}" // Get.log("22222characteristic.remoteId:${characteristic.remoteId}"

View File

@ -35,7 +35,7 @@ class StarLockMineLogic extends BaseGetXController {
state.userEmail.value = (await Storage.getEmail())!; state.userEmail.value = (await Storage.getEmail())!;
state.userHeadUrl.value = (await Storage.getHeadUrl())!; state.userHeadUrl.value = (await Storage.getHeadUrl())!;
Get.log("userNickName:${state.userNickName.value} userMobile:${state.userMobile.value} userEmail:${state.userEmail.value}"); Get.log("userNickName:${state.userNickName.value} userMobile:${state.userMobile.value} userEmail:${state.userEmail.value} userHeadUrl:${state.userHeadUrl.value}");
} }
} }

View File

@ -69,24 +69,24 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
Get.back(); Get.back();
Get.toNamed(Routers.minePersonInfoPage); Get.toNamed(Routers.minePersonInfoPage);
}, },
child: Container( child: Obx(() => Container(
width: 105.w, width: 105.w,
height: 105.w, height: 105.w,
// decoration: BoxDecoration( // decoration: BoxDecoration(
// borderRadius: // borderRadius:
// BorderRadius.all(Radius.circular(52.5.w)), // BorderRadius.all(Radius.circular(52.5.w)),
// ), // ),
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(52.5.w), borderRadius: BorderRadius.circular(52.5.w),
child: CustomNetworkImage(url:state.userHeadUrl.value??"", width:105.w, height:105.h), child: CustomNetworkImage(url:state.userHeadUrl.value??"", defaultUrl: 'images/controls_user.png', width:105.w, height:105.h),
), ),
// state.headUrl().isNotEmpty ? // state.headUrl().isNotEmpty ?
// Image(image: NetworkImage(state.loginData.value.data!.headUrl!)) : // Image(image: NetworkImage(state.loginData.value.data!.headUrl!)) :
// Image.asset( // Image.asset(
// 'images/mine/icon_mine_main_defaultAvatar.png', // 'images/mine/icon_mine_main_defaultAvatar.png',
// width: 60.w, // width: 60.w,
// height: 60.w) // height: 60.w)
), )),
), ),
SizedBox( SizedBox(
height: 20.h, height: 20.h,

View File

@ -1,3 +1,4 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -8,12 +9,12 @@ import '../../../../tools/baseGetXController.dart';
import '../../../tools/storage.dart'; import '../../../tools/storage.dart';
class MinePersonInfoEditNameLogic extends BaseGetXController { class MinePersonInfoEditNameLogic extends BaseGetXController {
final MinePersonInfoEditNamePageState state = final MinePersonInfoEditNamePageState state = MinePersonInfoEditNamePageState();
MinePersonInfoEditNamePageState();
//- //-
Future<void> updateUserInfoRequest() async { Future<void> updateUserInfoRequest() async {
var entity = var entity = await ApiRepository.to.updateUserNameInfo(
await ApiRepository.to.updateUserInfo(state.inputNickName.value); nickname: state.inputNickName.value,
);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast("操作成功"); showToast("操作成功");
final loginData = await Storage.getLoginData(); final loginData = await Storage.getLoginData();

View File

@ -1,7 +1,11 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../minePersonInfoPage/minePersonInfo_entity.dart';
class MinePersonInfoEditNamePageState { class MinePersonInfoEditNamePageState {
final mineInfoData = MinePersonInfoData().obs;
final TextEditingController nickNameController = TextEditingController(); final TextEditingController nickNameController = TextEditingController();
final inputNickName = ''.obs; final inputNickName = ''.obs;
@ -10,6 +14,8 @@ class MinePersonInfoEditNamePageState {
MinePersonInfoEditNamePageState() { MinePersonInfoEditNamePageState() {
Map map = Get.arguments; Map map = Get.arguments;
inputNickName.value = map["nickName"]; mineInfoData.value = map["mineInfoData"];
nickNameController.text = mineInfoData.value.nickname!;
inputNickName.value = mineInfoData.value.nickname!;
} }
} }

View File

@ -1,28 +1,31 @@
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart';
import '../../../../network/api_repository.dart'; import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart'; import '../../../../tools/baseGetXController.dart';
import '../../../tools/eventBusEventManage.dart';
import '../../../tools/storage.dart';
import 'minePersonGetUploadFileInfo_entity.dart'; import 'minePersonGetUploadFileInfo_entity.dart';
class MinePersonInfoLogic extends GetConnect { class MinePersonInfoLogic extends GetConnect {
final MinePersonInfoState state = MinePersonInfoState(); MinePersonInfoState state = MinePersonInfoState();
// //
Future<void> getUserInfoRequest() async { Future<void> getUserInfoRequest() async {
MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo(""); MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo();
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.mineInfoData.value = entity.data!; state.mineInfoData.value = entity.data!;
state.headUrl.value = state.mineInfoData.value.headUrl!;
} }
} }
// upToken updateUserInfo // upToken updateUserInfo
Future<void> getUpTokenRequest(String filename, int size) async { Future<void> getUpTokenRequest(String filename, int size) async {
var entity = await ApiRepository.to.getUpToken( var entity = await ApiRepository.to.getUpToken(
module: 'avatar', userId: state.mineInfoData.value.uid!.toString(),
typeKey: 'userId',
type: state.mineInfoData.value.uid!.toString(),
filename: filename, filename: filename,
size: size); size: size);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
@ -33,44 +36,32 @@ class MinePersonInfoLogic extends GetConnect {
// //
void uploadFile(MinePersonGetUploadFileInfoEntity minePersonGetUploadFileInfoEntity) async { void uploadFile(MinePersonGetUploadFileInfoEntity minePersonGetUploadFileInfoEntity) async {
// String json = JsonDecoder(minePersonGetUploadFileInfoEntity.data!.formData!);
// var formData = FormData();
//
// formData.files.add(MapEntry(
// "files", //
// MultipartFile(state.image!.path, filename: 'b'),
// ));
Map<String, dynamic> user = minePersonGetUploadFileInfoEntity.data!.formData!; Map<String, dynamic> user = minePersonGetUploadFileInfoEntity.data!.formData!;
user[minePersonGetUploadFileInfoEntity.data!.fileField!] = state.image!.path; var bytes = File(state.image!.path);
final form = FormData(user); var enc = await bytes.readAsBytes();
var entity = await ApiRepository.to.uploadFile( user[minePersonGetUploadFileInfoEntity.data!.fileField!] = enc;
url: minePersonGetUploadFileInfoEntity.data!.uploadUrl!, body: form);
if (entity.errorCode!.codeIsSuccessful) {}
// final formData = FormData.fromMap({
// 'file': await MultipartFile.fromFile(imageFile.path, contentType: MediaType.parse(mimeType))
// });
// final form = FormData(user);
// Response response= await post(minePersonGetUploadFileInfoEntity.data!.uploadUrl, form);
// print("statusText:${response.statusText} statusCode:${response.statusCode} response:$response");
}
void postCases(List<int> image) async {
final form = FormData({ final form = FormData({
'file': MultipartFile(image, filename: 'avatar.png'), 'file': MultipartFile(enc, filename: minePersonGetUploadFileInfoEntity.data!.formData!["key"]),
'otherFile': MultipartFile(image, filename: 'cover.png'),
}); });
Response response = await post('http://youapi/users/upload', form); var entity = await ApiRepository.to.uploadFile(url: minePersonGetUploadFileInfoEntity.data!.uploadUrl!, body: form);
if (entity.errorCode! == -1) {
// null成功
updateUserInfoRequest(minePersonGetUploadFileInfoEntity.data!.fileUrl!);
}
} }
//- //-
Future<void> updateUserInfoRequest() async { Future<void> updateUserInfoRequest(String headUrl) async {
var entity = await ApiRepository.to var entity = await ApiRepository.to.updateUserHeadUrlInfo(
.updateUserInfo(state.mineInfoData.value.headUrl!); headUrl: headUrl
);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.headUrl.value = headUrl;
state.mineInfoData.value.headUrl = state.headUrl.value!;
final loginData = await Storage.getLoginData();
loginData!.headUrl = headUrl;
await Storage.saveLoginData(loginData);
eventBus.fire(MineInfoChangeRefreshUI());
EasyLoading.showToast("操作成功", duration: 2000.milliseconds); EasyLoading.showToast("操作成功", duration: 2000.milliseconds);
} }
} }
@ -80,7 +71,6 @@ class MinePersonInfoLogic extends GetConnect {
// TODO: implement onReady // TODO: implement onReady
super.onReady(); super.onReady();
getUserInfoRequest();
} }
@override @override
@ -88,6 +78,7 @@ class MinePersonInfoLogic extends GetConnect {
// TODO: implement onInit // TODO: implement onInit
super.onInit(); super.onInit();
getUserInfoRequest();
} }
@override @override

View File

@ -60,20 +60,16 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
backgroundColor: AppColors.mainColor), backgroundColor: AppColors.mainColor),
body: Column( body: Column(
children: [ children: [
CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.avatar!.tr, leftTitel: TranslationLoader.lanKeys!.avatar!.tr,
rightTitle: "", rightTitle: "",
allHeight: 100.h, allHeight: 100.h,
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
isHaveRightWidget: true, isHaveRightWidget: true,
rightWidget: rightWidget: ClipRRect(
Container( borderRadius: BorderRadius.circular(36.w),
// color: Colors.orange, child: CustomNetworkImage(url:state.headUrl.value, defaultUrl: 'images/controls_user.png', width:72.w, height:72.w),
child: ClipRRect(
borderRadius: BorderRadius.circular(36.w),
child: CustomNetworkImage(url:"https://ui-avatars.com/api/?name=%E6%98%B5&color=7F9CF5&background=EBF4FF", width:72.w, height:72.w),
),
), ),
// ClipOval( // ClipOval(
// child: state.image != null // child: state.image != null
@ -102,7 +98,7 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
_openModalBottomSheet(); _openModalBottomSheet();
} }
}, },
), )),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.nickName!.tr, leftTitel: TranslationLoader.lanKeys!.nickName!.tr,
rightTitle: state.mineInfoData.value.nickname != null ? state.mineInfoData.value.nickname! : "", rightTitle: state.mineInfoData.value.nickname != null ? state.mineInfoData.value.nickname! : "",
@ -110,7 +106,7 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Navigator.pushNamed(context, Routers.minePersonInfoEditNamePage, Navigator.pushNamed(context, Routers.minePersonInfoEditNamePage,
arguments: {'nickName': state.mineInfoData.value.nickname}) arguments: {'mineInfoData': state.mineInfoData.value})
.then((value) => logic.getUserInfoRequest()); .then((value) => logic.getUserInfoRequest());
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
@ -280,9 +276,11 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
int getSelectIndex = value; int getSelectIndex = value;
if (getSelectIndex == 0) { if (getSelectIndex == 0) {
// //
state.hasCameraPermission.value == true ? selectCamera() : _requestCameraPermission(); // state.hasCameraPermission.value == true ? selectCamera() : _requestCameraPermission();
_checkCameraPermission();
} else if (getSelectIndex == 1) { } else if (getSelectIndex == 1) {
state.hasPhotoPermission.value == true ? selectImage() : _requestPhotoPermission(); // state.hasPhotoPermission.value == true ? selectImage() : _requestPhotoPermission();
_checkPhotoPermission();
} }
}, },
); );
@ -294,8 +292,9 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
XFile? photo = await state.imagePicker.pickImage(source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear); XFile? photo = await state.imagePicker.pickImage(source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear);
if (photo != null) { if (photo != null) {
state.image = photo; state.image = photo;
// logic.getUpTokenRequest(); var bytes = File(state.image!.path);
setState(() {}); var enc = await bytes.readAsBytes();
logic.getUpTokenRequest(state.image!.name, enc.length);
} }
} }
@ -310,37 +309,28 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
state.image = image; state.image = image;
var bytes = File(state.image!.path); var bytes = File(state.image!.path);
var enc = await bytes.readAsBytes(); var enc = await bytes.readAsBytes();
print(enc.length);
print(
"state.image!.path:${state.image!.path} state.image!.name:${state.image!.name} state.image!.length():${state.image!.length()}");
logic.getUpTokenRequest(state.image!.name, enc.length); logic.getUpTokenRequest(state.image!.name, enc.length);
setState(() {});
} }
} }
Future<void> _checkCameraPermission() async { Future<void> _checkCameraPermission() async {
var status = await Permission.camera.status; var status = await Permission.camera.status;
if (status.isGranted) { if (status.isGranted) {
setState(() { selectCamera();
state.hasCameraPermission.value = true; //
});
} else { } else {
setState(() { _requestCameraPermission();
state.hasCameraPermission.value = false; //
});
} }
} }
Future<void> _checkPhotoPermission() async { Future<void> _checkPhotoPermission() async {
var status = await Permission.photos.status; var status = await Permission.photos.status;
if (status.isGranted) { if (status.isGranted) {
setState(() { selectImage();
state.hasPhotoPermission.value = true; //
});
} else { } else {
setState(() { // setState(() {
state.hasPhotoPermission.value = false; // // state.hasPhotoPermission.value = false; //
}); // });
_requestPhotoPermission();
} }
} }

View File

@ -4,6 +4,7 @@ import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_
class MinePersonInfoState { class MinePersonInfoState {
final mineInfoData = MinePersonInfoData().obs; final mineInfoData = MinePersonInfoData().obs;
final headUrl = ''.obs;
var typeStr = '2'.obs; //2: var typeStr = '2'.obs; //2:
@ -15,4 +16,6 @@ class MinePersonInfoState {
var hasPhotoPermission = false.obs; // var hasPhotoPermission = false.obs; //
var hasCameraPermission = false.obs; // var hasCameraPermission = false.obs; //
} }

View File

@ -175,8 +175,7 @@ abstract class Api {
'/safeAnswer/getOwnQuestionList'; // '/safeAnswer/getOwnQuestionList'; //
final String updateSafeAnswerURL = '/safeAnswer/update'; // final String updateSafeAnswerURL = '/safeAnswer/update'; //
final String setSafeAnswerURL = '/safeAnswer/set'; // final String setSafeAnswerURL = '/safeAnswer/set'; //
final String getUpTokenURL = final String getUpTokenURL = '/file/getUploadParams'; // upToken updateUserInfo
'/file/getUploadParams'; // upToken updateUserInfo
final String unbindPhoneTokenURL = '/user/unbindPhoneToken'; //Token final String unbindPhoneTokenURL = '/user/unbindPhoneToken'; //Token
final String unbindEmailTokenURL = '/user/unbindEmailToken'; //Token final String unbindEmailTokenURL = '/user/unbindEmailToken'; //Token
final String pushBindAppIdURL = '/user/bindAppId'; //APP设备 final String pushBindAppIdURL = '/user/bindAppId'; //APP设备

View File

@ -1555,9 +1555,17 @@ class ApiProvider extends BaseProvider {
'xWidth': xWidth, 'xWidth': xWidth,
})); }));
//-/ //-
Future<Response> updateUserInfo(String nickname) => Future<Response> updateUserNameInfo(String nickname) =>
post(updateUserInfoURL.toUrl, jsonEncode({'nickname': nickname})); post(updateUserInfoURL.toUrl, jsonEncode({
'nickname': nickname,
}));
//-
Future<Response> updateUserHeadUrlInfo(String headUrl) =>
post(updateUserInfoURL.toUrl, jsonEncode({
'headUrl': headUrl,
}));
// //
Future<Response> bindPhone(String countryCode, String account, Future<Response> bindPhone(String countryCode, String account,
@ -1617,20 +1625,23 @@ class ApiProvider extends BaseProvider {
jsonEncode({"questionAndAnswerList": questionAndAnswerList})); jsonEncode({"questionAndAnswerList": questionAndAnswerList}));
// upToken updateUserInfo // upToken updateUserInfo
Future<Response> getUpToken(String module, String typeKey, String type, Future<Response> getUpHeadToken(
String filename, int size) => String userId,
String filename,
int size,
) =>
post( post(
getUpTokenURL.toUrl, getUpTokenURL.toUrl,
jsonEncode({ jsonEncode({
"module": module, "module": "avatar",
typeKey: type, "userId": userId,
"filename": filename, "filename": filename,
"size": size, "size": size,
})); }));
// //
Future<Response> uploadFile(String url, dynamic boay) => post(url, boay, Future<Response> uploadFile(String url, dynamic boay) => post(url, boay,
isUnUploadFile: false, contentType: 'multipart/form-data'); isUnUploadFile: false, contentType: 'multipart/form-data', isUserBaseUrl: false);
//Token //Token
Future<Response> unbindPhoneToken(String verificationCode) => post( Future<Response> unbindPhoneToken(String verificationCode) => post(

View File

@ -29,10 +29,17 @@ class BaseProvider extends GetConnect with Api {
Decoder<T>? decoder, Decoder<T>? decoder,
bool? isUnUploadFile = true, bool? isUnUploadFile = true,
Progress? uploadProgress, Progress? uploadProgress,
bool? isUnShowLoading = false}) async { bool? isUnShowLoading = false,// loading
bool? isUserBaseUrl = true,// 使baseUrl
}) async {
// print("post: url:${url} body:${body} contentType:${contentType} headers:${headers} query:${query}"); // print("post: url:${url} body:${body} contentType:${contentType} headers:${headers} query:${query}");
if (isUnShowLoading == false) EasyLoading.show(); if (isUnShowLoading == false) EasyLoading.show();
// print('请求url======>$url'); // print('请求url======>$url');
if (isUserBaseUrl == false){
httpClient.baseUrl = '';
}else{
httpClient.baseUrl = '${F.apiPrefix}/api';
}
print('请求body体======>$body'); print('请求body体======>$body');
var res = await super.post(url, body, var res = await super.post(url, body,
contentType: contentType, contentType: contentType,
@ -59,7 +66,7 @@ class BaseProvider extends GetConnect with Api {
statusText: res.statusText, statusText: res.statusText,
); );
} else {} } else {}
// print('得到的数据======>${res.bodyString}'); print('得到的数据======>${res.bodyString}');
getDataResult(res.body); getDataResult(res.body);
return res; return res;
} }

View File

@ -1573,8 +1573,8 @@ class ApiRepository {
} }
// //
Future<MinePersonInfoEntity> getUserInfo(String operatorUid) async { Future<MinePersonInfoEntity> getUserInfo() async {
final res = await apiProvider.getUserInfo(operatorUid); final res = await apiProvider.getUserInfo("");
return MinePersonInfoEntity.fromJson(res.body); return MinePersonInfoEntity.fromJson(res.body);
} }
@ -1596,9 +1596,21 @@ class ApiRepository {
return SendValidationCodeEntity.fromJson(res.body); return SendValidationCodeEntity.fromJson(res.body);
} }
//-/ //-
Future<PasswordKeyListEntity> updateUserInfo(String nickname) async { Future<PasswordKeyListEntity> updateUserNameInfo(
final res = await apiProvider.updateUserInfo(nickname); {
required String nickname,
}) async {
final res = await apiProvider.updateUserNameInfo(nickname);
return PasswordKeyListEntity.fromJson(res.body);
}
//-
Future<PasswordKeyListEntity> updateUserHeadUrlInfo(
{
required String headUrl
}) async {
final res = await apiProvider.updateUserHeadUrlInfo(headUrl);
return PasswordKeyListEntity.fromJson(res.body); return PasswordKeyListEntity.fromJson(res.body);
} }
@ -1652,14 +1664,13 @@ class ApiRepository {
} }
// upToken updateUserInfo // upToken updateUserInfo
Future<MinePersonGetUploadFileInfoEntity> getUpToken( Future<MinePersonGetUploadFileInfoEntity> getUpToken({
{required String module, required String userId,
required String typeKey, required String filename,
required String type, required int size,
required String filename, }) async {
required int size}) async {
final res = final res =
await apiProvider.getUpToken(module, typeKey, type, filename, size); await apiProvider.getUpHeadToken(userId, filename, size);
return MinePersonGetUploadFileInfoEntity.fromJson(res.body); return MinePersonGetUploadFileInfoEntity.fromJson(res.body);
} }

View File

@ -4,8 +4,7 @@ import 'package:get/get.dart';
import 'package:get/get_connect/http/src/request/request.dart'; import 'package:get/get_connect/http/src/request/request.dart';
FutureOr<dynamic> responseLogInterceptor(Request request, Response response) { FutureOr<dynamic> responseLogInterceptor(Request request, Response response) {
Get.log( // Get.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString} ${response.headers}');
'HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString} ${response.headers}');
EasyLoading.dismiss(animation: true); EasyLoading.dismiss(animation: true);
return response; return response;
} }

View File

@ -8,14 +8,15 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
class CustomNetworkImage extends StatelessWidget { class CustomNetworkImage extends StatelessWidget {
final String url; final String url;
final String defaultUrl;
final double width; final double width;
final double height; final double height;
final BoxFit boxFit; final BoxFit boxFit;
const CustomNetworkImage({Key? key, required this.url, required this.width, required this.height, this.boxFit=BoxFit.cover}) : super(key: key); const CustomNetworkImage({Key? key, required this.url, required this.defaultUrl, required this.width, required this.height, this.boxFit=BoxFit.cover}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CachedNetworkImage( return url.isNotEmpty ? CachedNetworkImage(
width: width, width: width,
height: height, height: height,
fit: boxFit, fit: boxFit,
@ -28,7 +29,17 @@ class CustomNetworkImage extends StatelessWidget {
colorFilter: const ColorFilter.mode(Colors.transparent, BlendMode.colorBurn)), colorFilter: const ColorFilter.mode(Colors.transparent, BlendMode.colorBurn)),
), ),
), ),
errorWidget: (context, url, error) => Icon(Icons.error,size: 40.sp) errorWidget: (context, url, error) => Image.asset(
defaultUrl,
width: width,
height: height,
fit: BoxFit.fill,
),
) :Image.asset(
defaultUrl,
width: width,
height: height,
fit: BoxFit.fill,
); );
} }
} }

View File

@ -187,7 +187,7 @@ class Storage {
if (data != null && data.isNotEmpty) { if (data != null && data.isNotEmpty) {
loginData = LoginData.fromJson(jsonDecode(data)); loginData = LoginData.fromJson(jsonDecode(data));
} }
print("loginData:$loginData"); // print("loginData:$loginData");
return loginData; return loginData;
} }

View File

@ -78,6 +78,7 @@ class VersionUndateTool {
builder: (context) { builder: (context) {
return CupertinoAlertDialog( return CupertinoAlertDialog(
content: Column( content: Column(
mainAxisSize: MainAxisSize.min,
children: [ children: [
Container( Container(
// color: AppColors.mainColor, // color: AppColors.mainColor,