tbib_dio_extension

Creator: coderz1093

Last updated:

0 purchases

tbib_dio_extension Image
tbib_dio_extension Images

Languages

Categories

Add to Cart

Description:

tbib dio extension

TBIB Dio Extension #
Import #
import 'package:tbib_dio_extension/tbib_dio_extension.dart';
copied to clipboard
How To Use #
Use In Repository
if (await networkInfo.isConnected) {
try {
var res = await appServicesClient.getSettings();
if (res.isSuccess) {
return Success(res.toModel);
} else {
return Error(Failure(res.statusCode, res.errorMessage));
}
} catch (error) {
return Error(ErrorHandler.handle(error).failure);
}
} else {
//failure
// return either left
return Error(DataSource.NO_INTERNET_CONNECTION.getFailure());
}

copied to clipboard
use in any thing
// in main it removed in v 1.0.0 baseUrl optional
DioManger.init(baseUrl: 'baseUrl');


// for custom option
DioManger.initWithCustomOption();

// get dio
var dio = DioManger.dioApi;

// call api
try
{
var res= await dio.post('endpoint');
}
catch(error)
{
// get error from dio
ErrorHandler.handle(error).failure.messages;
}
/* you can get error from api
example response api
{
"result": null,
"errorMessage": "Invalid userName Or Password",
}
*/

ErrorHandler.handle(error, messageFromApi: (error is DioError) ? error.response?.data['errorMessage'] : null).failure.messages;


copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.