unleash_proxy 0.2.0 copy "unleash_proxy: ^0.2.0" to clipboard
unleash_proxy: ^0.2.0 copied to clipboard

outdated

Unleash Flutter Proxy SDK

Unleash Flutter Proxy SDK #

pub package pub points style: very good analysis Powered by Mason License: MIT

This library is meant to be used with the unleash-proxy. The proxy application layer will sit between your unleash instance and your client applications, and provides performance and security benefits. DO NOT TRY to connect this library directly to the unleash instance, as the datasets follow different formats because the proxy only returns evaluated toggle information.

Installation ๐Ÿ’ป #

โ— In order to start using Unleash you must have the Flutter SDK installed on your machine.

Add unleash_proxy to your pubspec.yaml:

dependencies:
  unleash_proxy:

Install it:

flutter packages get

Usage #

To use the unleash_proxy to Flutter application, initialize unleash_proxy first:

Unleash Environment #

Create unleash_environment.dart file to save environment variables:

import 'package:flutter/services.dart';
import 'package:unleash_proxy/unleash_proxy.dart';

class UnleashEnvironment {
  static UnleashConfig get config => UnleashConfig(
    proxyUrl: 'https://UNLEASH_URL/proxy',
    clientKey: 'CLIENT_KEY',
  );

  static UnleashContext get context => UnleashContext();
}

class ToggleKeys {
  static String experiment = 'toggle-experiment';
}

Initialize Unleash Proxy #

Initialize unleash_proxy to the main file:


import 'package:example/unleash_environment.dart';
import 'package:flutter/material.dart';

/// Import package here
import 'package:unleash_proxy/unleash_proxy.dart';

Future<void> main() async {
  /// You only need to call this method if you need the binding to be
  /// initialized before calling [runApp].
  WidgetsFlutterBinding.ensureInitialized();

  /// Initialize unleash client here
  await Unleash.initializeApp(
    config: UnleashEnvironment.config,
    context: UnleashEnvironment.context,
  );

  runApp(const App());
}

Use Unleash Proxy Toggle #

import 'package:example/unleash_environment.dart';
import 'package:flutter/material.dart';
import 'package:unleash_proxy/unleash_proxy.dart';

class ExampleScreen extends StatelessWidget {
  const ExampleScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('First Screen'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'Toggle Status',
              style: TextStyle(height: 2.5, fontWeight: FontWeight.w500),
            ),
            toggleStatus(),
          ],
        ),
      ),
    );
  }

  Widget toggleStatus() {
    /// Call [isEnabled] to get the toggle value
    final status = Unleash.isEnabled(ToggleKeys.experiment);

    return Text(status == true ? 'Enabled' : 'Disabled');
  }
}

Can check the example here

Continuous Integration ๐Ÿค– #

Unleash Flutter Proxy SDK comes with a built-in GitHub Actions workflow powered by Very Good Workflows but you can also add your preferred CI/CD solution.

Out of the box, on each pull request and push, the CI formats, lints, and tests the code. This ensures the code remains consistent and behaves correctly as you add functionality or make changes. The project uses Very Good Analysis for a strict set of analysis options used by our team. Code coverage is enforced using the Very Good Workflows.


Running Tests ๐Ÿงช #

For first time users, install the very_good_cli:

dart pub global activate very_good_cli

To run all unit tests:

very_good test --coverage

To view the generated coverage report you can use lcov.

# Generate Coverage Report
genhtml coverage/lcov.info -o coverage/

# Open Coverage Report
open coverage/index.html

Issues #

Please file any issues, bugs or feature requests as an issue on the GitHub page. Commercial support is available, you can contact me at rizentium@gmail.com.

Author #

This unleash_proxy plugin for Flutter is developed by Arif Hidayat.

1
likes
0
points
8
downloads

Publisher

unverified uploader

Weekly Downloads

Unleash Flutter Proxy SDK

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, flutter, http, uuid

More

Packages that depend on unleash_proxy