Search packages, repositories and app categories

GitHub repositorygabuldev/dio_interceptors

dio_interceptors

gabuldev/dio_interceptors open-source repository details.

dio_interceptors project cover
Stars
3
Forks
1
Last push (UTC)
Mar 21, 2023
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

dio_interceptors

A interceptors to use on Dio.

INTERCEPTORS

Interceptor Mock

You use for mock API requests.


void main() {
  Dio dio = Dio();

  var mockData = {
     "/test" : {
       "name" : "Gabul DEV",
       "site" : "https://gabul.dev"
     }
   };
   dio.interceptors.add(InterceptorMock(mockData));

   void getData() async{
       var res = await dio.get("/test");
      print(res.data["name"])// "Gabul DEV" 
      print(res.data["site"])// "https://gabul.dev"); 
   }
    
    getData();
}

Interceptor Token

You can use for add JWT all requests

Future<String> token() async{
  //Implements your logic here
  return jwt;
}

dio.interceptors.add(InterceptorToken(token: () async => await token()))

Gabul - GDE Flutter & Dart GitHub avatar
GitHub author

Gabul - GDE Flutter & Dart ↗

Founder of Gabuldev, Specialist in Mobile Development, participates in the Google Developer Expert in Flutter & Dart, organizer of the GDG Nova Lima

Brazil
LanguagesDartSwiftKotlinObjective-C

Packages published by this repository

Dependencies used

Dependency list 3 items

  • dio^4.0.0-beta2
  • flutter{"sdk":"flutter"}
  • flutter_testDevelopment{"sdk":"flutter"}

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗