Vexana is easy to use network proccess with dio. You can do dynamic model parsing, base error model, timeout and many utility functions.


Getting Started 🔥

Let's talk about usage details.

Network Manager 😎

Have a lot of options: baseurl, logger, interceptors, base model etc.

INetworkManager  networkManager = NetworkManager(isEnableLogger: true, errorModel: UserErrorModel(),
 options: BaseOptions(baseUrl: ""));

Model Parse ⚔️

First, you have to provide the parse model, then the result model. (Result model could be a list, model or primitive)

final response =
await networkManager.send<Todo, List<Todo>>("/todos", parseModel: Todo(), method: RequestType.GET);

Base Headers 📍

You could be add key values to your every request directly.(add authhentication key)

networkManager.addBaseHeader(MapEntry(HttpHeaders.authorizationHeader, ?? ''));
// Clear singlhe header
// Clear all hader

Download File 📍

You can download any file format like pdf, png or etc with progress indicator.

final response = await networkManager.downloadFileSimple('', (count, total) {

//Example: Image.memory(

HTTP Post Request with Request Body 🚀

The model found in the request body must extend the abstract class INetworkModel, as follows.

class TodoPostRequestData extends INetworkModel<TodoPostRequestData>

Then, since the model will have toJson and fromJson properties, you can create the object and pass it directly to the send method.

So, it is sufficient to send only the request body object into the send method. You don't need to use toJson.

final todoPostRequestBody = TodoPostRequestData();
final response =
await networkManager.send<Todo, List<Todo>>("/todosPost", parseModel: Todo(), method: RequestType.POST, data: todoPostRequestBody);

Network Model 🛒

You must wrap your model with INetworkModel so that, we understand model has toJson and fromJson methods.

class Todo extends INetworkModel<Todo>

Refresh Token ♻️

Many projects use authentication structure for mobile security (like a jwt). It could need to renew an older token when the token expires. This time provided a refresh token option, we can lock all requests until the token refresh process is complete.

Since i locked all requests, I am giving a new service instance.

INetworkManager  networkManager = NetworkManager(isEnableLogger: true, options: BaseOptions(baseUrl: "",
onRefreshFail: () {  //Navigate to login },
 onRefreshToken: (error, newService) async {
    <!-- Write your refresh token business -->
    <!-- Then update error.req.headers to new token -->
    return error;

Caching 🧲

You need to write a response model in the mobile device cache sometimes. It's here now. You can say expiration date and lay back 🙏

    await networkManager.send<Todo, List<Todo>>("/todos",
        parseModel: Todo(),
        expiration: Duration(seconds: 3),
        method: RequestType.GET);

You must declare a caching type. It has FileCache and SharedCache options now. NetworkManager(fileManager: LocalFile()); If you want more implementation details about the cache, you should read this article


  • x Example project
  • x Unit Test with json place holder
  • x Unit Test with custom api
  • Make a unit test all layers.
  • x Cache Option
    • SQlite Support
    • Web Cache Support
  • x Refresh Token Architecture
  • Usage Utility



2020 created for @VB10

Youtube Channel