import 'dart:async'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:get/get_connect/http/src/request/request.dart'; import 'package:dreampad/app/models/models.dart'; FutureOr adapterInterceptor(Request request, Response response) async { if (response.body != null && response.statusCode == 200) { BaseResponse result = BaseResponse.fromJson(response.body); if (result.code == 200 && result.success!) { return Response( headers: response.headers, request: request, statusCode: response.statusCode, body: result.data, ); } else { if (result.errors != null && result.errors!.isNotEmpty) { SmartDialog.showToast(result.errors![0].description!); return Response( headers: response.headers, request: request, statusCode: response.statusCode, body: null, ); } } } return response; }