fresh 0.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

fresh 🍋 #

Pub build coverage style: effective dart License: MIT


An token refresh library for dart. This package exposes the core components that are common to various refresh token implementations (REST, GraphQL, etc...).

PackagePub
fresh_diopub package
fresh_graphqlpub package

0.2.1 #

  • Add InMemoryTokenStorage
  • Add TokenHeaderBuilder typedef

0.2.0 #

  • BREAKING: split dio interceptor into separate package (fresh_dio)
    • package:fresh is repurposed to contain core refresh components

0.1.0 #

  • Improvements to internal implementation
  • Fully Unit Tested

0.0.3 #

  • Fix: expose DioErrors to shouldRefresh function (#9)

0.0.2 #

  • BREAKING: convert to dio interceptor.

0.0.1 #

Initial Release of the library.

  • Includes FreshClient with built-in token refresh.

example/main.dart

import 'package:fresh/fresh.dart';

class InMemoryTokenStorage implements TokenStorage<OAuth2Token> {
  OAuth2Token _token;

  @override
  Future<void> delete() async {
    _token = null;
  }

  @override
  Future<OAuth2Token> read() async {
    return _token;
  }

  @override
  Future<void> write(OAuth2Token token) async {
    _token = token;
  }
}

void main() {
  // Configure appropriate fresh client using `TokenStorage` implementation.
  // For example using [fresh_dio](https://pub.dev/packages/fresh_dio)...
  /// ```dart
  /// final dio = Dio()
  ///   ..interceptors.add(
  ///     Fresh<OAuth2Token>(
  ///       tokenStorage: InMemoryTokenStorage(),
  ///       refreshToken: (token, client) {
  ///         // Perform refresh and return new token
  ///       },
  ///     ),
  ///   );
  // ```
}

Use this package as a library

1. Depend on it

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


dependencies:
  fresh: ^0.2.1

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/fresh.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
78
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.15

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
meta ^1.1.8 1.2.2 1.3.0-nullsafety
Dev dependencies
effective_dart ^1.2.1
mockito ^4.1.1
test ^1.14.3
test_coverage ^0.4.1