fresh_dio 0.1.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 83

fresh_dio 🍋 #

Pub build coverage style: effective dart License: MIT

A dio interceptor for built-in token refresh. Built to be used with fresh.

Overview #

fresh_dio is a dio interceptor which attempts to simplify custom API authentication by integrating token refresh and caching transparently. fresh_dio is flexible and is intended to support custom token refresh mechanisms.

Usage #

    tokenStorage: InMemoryTokenStorage(),
    refreshToken: (token, client) {
      // Perform refresh and return new token

Example #

See the example for a complete sample application using fresh_dio which integrates with jsonplaceholder.

0.1.3 #

  • fix: handle null response in onResponse (#24).

0.1.2 #

  • fix: add generic <T> parameter to TokenHeaderBuilder (#22).

0.1.1 #

  • Update to fresh v0.2.1

0.1.0 #

Initial Release of the library (copy of package:fresh v0.2.0)

  • Includes Fresh interceptor with built-in token refresh.


import 'package:flutter/material.dart';
import 'package:fresh_example/app/app.dart';
import 'package:fresh_example/simple_bloc_delegate.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:jsonplaceholder_client/jsonplaceholder_client.dart';
import 'package:photos_repository/photos_repository.dart';
import 'package:user_repository/user_repository.dart';

void main() {
  BlocSupervisor.delegate = SimpleBlocDelegate();
  final jsonplaceholderClient = JsonplaceholderClient();
  final photosRepository = PhotosRepository(jsonplaceholderClient);
  final userRepository = UserRepository(jsonplaceholderClient);

    photosRepository: photosRepository,
    userRepository: userRepository,

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  fresh_dio: ^0.1.3

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:fresh_dio/fresh_dio.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
dio ^3.0.9 3.0.9
fresh ^0.2.1 0.2.1
meta ^1.1.8 1.1.8
Transitive dependencies
charcode 1.1.3
collection 1.14.13
http_parser 3.1.4
path 1.7.0
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0
Dev dependencies
effective_dart ^1.2.1
mockito ^4.1.1
test ^1.14.3
test_coverage ^0.4.1