ajustee_client 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

ajustee_client #

Ajustee flutter client

Public Method Summary #

In this table you can find the different functions exposed by this plugin:

ReturnDescription
AjusteeClientAjusteeClient(String apiUrl, String applicationId, String socketUrl, String trackerId: null, Map<String, String> defaultProperties: {}, String defaultPath: null, bool reconnect: true, int reconnectTimeout = 5000 )
Request configuration params list. Return a list with ConfigurationKeys.
async voidsubscribe(String path: null, Map<String, String> properties: {})
Subscribe for changes of configuration key by path.
async voidunsubscribe(String path: null)
Unsubscribe for changes of configuration key by path.
async Future<ListgetConfigurations(String path: null, Map<String, String> properties: {})
Request configuration params list. Return a list with ConfigurationKeys.
Stream<ListonChanged()
Get the stream of the configurations changes.
Stream<ConfigurationKey>onKeyChanged()
Get the stream of the single configurations key changes.
Stream<String>onDeleted()
Get the stream of the configurations changes.

[1.0.2] - 24.02.2020 #

  • Update example

[1.0.0] - 22.02.2020 #

  • Initial release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:ajustee_client/ajustee_client.dart';
import 'package:ajustee_client/models/configuration_key.dart';
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Ajustee client',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyExamplePage(title: 'Example Page'),
    );
  }
}

class MyExamplePage extends StatefulWidget {
  MyExamplePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyExamplePageState createState() => _MyExamplePageState();
}

class _MyExamplePageState extends State<MyExamplePage> {
  AjusteeClient ajusteeClient;
  void _getConfiguration() async{
    List<ConfigurationKey> configKeys = await this.ajusteeClient.getConfigurations();

    configKeys.forEach((item) {
      print('${item.path} ${item.dataType} ${item.value}');
    });
  }

  void _saveConfiguration() async{
    this.ajusteeClient.saveConfigurations(path: 'myAwesomeFeature/IsEnabled', value: 'true');
  }

  void _subscribe() async{
    ajusteeClient.subscribe('myAwesomeFeature/IsEnabled', properties: {});

    ajusteeClient.onChanged().listen((List<ConfigurationKey> keys) {
      print("onChanged:");
      keys.forEach((item) {
        print('Path: ${item.path} Type: ${item.dataType} Value: ${item.value}');
      });
    });

    ajusteeClient.onKeyChanged().listen((ConfigurationKey key) {
        print('onKeyChanged: Path: ${key.path} Type: ${key.dataType} Value: ${key.value}');
    });

    ajusteeClient.onDeleted().listen((String path) {
      print("onDeleted $path");
    });
  }

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }
  Future<void> initPlatformState() async {
  this.ajusteeClient = AjusteeClient(
      apiUrl: 'https://api.ajustee.com',
      socketUrl: 'wss://ws.ajustee.com',
      applicationId: 'diGBVHK4yus6A4bkg9O5AX~Xv.cvFdVw'
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            RaisedButton(
              onPressed: _getConfiguration,
              child: const Text('Get Configuration', style: TextStyle(fontSize: 20)),
            ),
            const SizedBox(height: 30),
            RaisedButton(
              onPressed: _saveConfiguration,
              child: const Text('Save Configurations', style: TextStyle(fontSize: 20)),
            ),
            const SizedBox(height: 30),
            RaisedButton(
              onPressed: _subscribe,
              child: const Text('Subscribe', style: TextStyle(fontSize: 20)),
            ),
          ],
        ),
      ),
   );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  ajustee_client: ^1.0.2

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

Analysis suggestions

Package not compatible with runtime flutter-web on web

Because of the import of dart:io via the import chain package:ajustee_client/ajustee_client.dartpackage:ajustee_client/services/socket_provider.dartpackage:ajustee_client/services/socket_client.dartpackage:web_socket_channel/io.dartdart:io

Package not compatible with runtime web

Because of the import of dart:io via the import chain package:ajustee_client/ajustee_client.dartpackage:ajustee_client/services/socket_provider.dartpackage:ajustee_client/services/socket_client.dartpackage:web_socket_channel/io.dartdart:io

Health issues and suggestions

Document public APIs. (-0.55 points)

129 out of 131 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/models/configuration_key.dart.

Run dartfmt to format lib/models/configuration_key.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
http ^0.12.0+4 0.12.1
intl ^0.16.1 0.16.1
meta ^1.1.8 1.2.2 1.3.0-nullsafety
web_socket_channel ^1.1.0 1.1.0
Transitive dependencies
async 2.4.2
charcode 1.1.3
collection 1.14.13 1.15.0-nullsafety
convert 2.1.1
crypto 2.1.5
http_parser 3.1.4
path 1.7.0
pedantic 1.9.2
source_span 1.7.0
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0 1.3.0-nullsafety
Dev dependencies
test ^1.12.0