unleash 0.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 69

Pub GitHub Workflow Status

Unleash Client SDK for Dart and Flutter #

This is an unofficial Unleash Client SDK for Dart. It is compatible with the Unleash-hosted.com SaaS offering and Unleash Open-Source. It also works with GitLab Feature Flags.

Getting started #

First, you will need to add unleash to your pubspec.yaml:

dependencies:
  unleash: x.y.z 
  # use the latest version found on pub.dev

Then, run flutter packages get in your terminal.

Create a new Unleash instance #

It is easy to get a new instance of Unleash. In your app you typically just want one instance of Unleash, and inject that where you need it.

To create a new instance of Unleash you need to pass in a config object:

import 'package:unleash/unleash.dart';

Future<void> main() async {
  final unleash = await Unleash.init(
    UnleashSettings(
      appName: '<appname>',
      instanceId: '<instanceid>',
      unleashApi: Uri.parse('<api_url>'),
    ),
  );
  print(unleash.isEnabled('Awesome Feature'));
}

Awesome feature toggle API #

It is really simple to use unleash.

if(unleash.isEnabled("AwesomeFeature")) {
  //do some magic
} else {
  //do old boring stuff
}

Calling Unleash.isEnabled("AwesomeFeature") is the equivalent of calling Unleash.isEnabled("AwesomeFeature", defaultValue: false). Which means that it will return false if it cannot find the named toggle.

If you want it to default to true instead, you can pass true as the second argument:

unleash.isEnabled("AwesomeFeature", defaultValue: true);

Current state of development #

This client SDK supports version 3 of the API.

This SDK currently does not support any strategies, metrics reporting or anything else. It just gets the feature toggels yet.

[0.0.5] #

  • added periodic toggle polling
  • added ability to persist feature toggle backups

[0.0.4] #

  • API changes

[0.0.3] #

  • pubspec update

[0.0.1] #

  • initial release

example/example.dart

import 'dart:async';

import 'package:unleash/unleash.dart';

Future<void> main() async {
  final unleash = await Unleash.init(
    UnleashSettings(
      appName: 'debug',
      instanceId: 'Q8XiLix59zo2NytFGd1b',
      unleashApi:
          Uri.parse('https://gitlab.com/api/v4/feature_flags/unleash/18585314'),
    ),
    onUpdate: () {
      print('refreshed feature toggles');
    },
  );
  print(unleash.isEnabled('awesome_feature'));
  // wait some time so that toggles can be polled a few times
  // and dispose unleash at the end of it
  Timer(
    const Duration(seconds: 60),
    unleash.dispose,
  );
  print('finished');
}

Use this package as a library

1. Depend on it

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


dependencies:
  unleash: ^0.0.5

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

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.8.0 <3.0.0
http >=0.11.0 <2.0.0 0.12.1
meta >=1.0.0 <2.0.0 1.1.8
path ^1.6.0 1.7.0
Transitive dependencies
charcode 1.1.3
collection 1.14.13
http_parser 3.1.4
pedantic 1.9.0 1.9.1
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0
Dev dependencies
test >=0.12.0 <2.0.0
yaml >=2.1.0 <3.0.0