fh_sdk 0.6.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 45

fh_sdk #

Unofficial flutter plugin for Red Hat Mobile. This plugin uses both Android and iOS Red Hat Mobile SDK, you can find further information herehttps://access.redhat.com/documentation/en-us/red_hat_mobile_application_platform_hosted/3/html/client_sdk/.

Usage #

Prior to importing the plugin make sure your configuration files for Android and iOS are placed in the default location for each platform. As part of this plugin we provide an example project already set up with a dummy configuration file.

Importing the plugin #

Import package:fh_sdk/fh_sdk.dart, instantiate FH and invoke one of the supported operations as in the following example. Take into account that you have to initialize the plugin before invoking any other operation.

Example of initialization:

import 'package:fh_sdk/fh_sdk.dart';

String result;
String message = 'Init call running';

try {
    result = await FhSdk.init();
    print('initResult' + result);
    message = result.toString();
} on PlatformException catch (e) {
    message = 'Error in FH Init $e';
}

You will find links to the API docs on the pub page.

Getting Started #

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fh_sdk/fh_sdk.dart';

void main() => runApp(new MyApp());

class TitleSection extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Container(
      padding: const EdgeInsets.all(32.0),
      child: new Row(
        children: [
          new Expanded(
            child: new Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                
                new Text('This is just and example Flutter app using the hello endpoint. Please, type something (your name for instance) and hit the button',
                  style: new TextStyle(
                    color: Colors.grey[500],
                  ),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _fhInit = false;
  String _messages = 'No messages';

  @override
  initState() {
    super.initState();
    initFHState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  initFHState() async {
    String result;
    String message = 'Init call running';

    try {
      result = await FhSdk.init();
      print('initResult' + result);
      message = result.toString();
    } on PlatformException catch (e) {
      message = 'Error in FH Init $e';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted)
      return;

    setState(() {
      _fhInit = result != null && result.contains('SUCCESS') ? true : false;
      _messages = message;
    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  getCloudUrl() async {
    String result;
    String message;

    try {
      result = await FhSdk.getCloudUrl();
      print('cloudHost' + result);
      message = result.toString();
    } on PlatformException catch (e) {
      message = 'Error in FH getCloudUrl $e';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted)
      return;

    setState(() {
      _messages = message;
    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  sayHello(String name) async {
    dynamic data;
    String message;

    String hello = (name == null || name.length <=0) ? 'world' : name;

    try {
      Map options = {
        "path": "/hello?hello=" + hello.replaceAll(' ', ''),
        "method": "GET",
        "contentType": "application/json",
        "timeout": 25000 // timeout value specified in milliseconds. Default: 60000 (60s)
      };
      data = await FhSdk.cloud(options);
      print('data ==> ' + data.toString());
      message = data.toString();
    } on PlatformException catch (e, s) {
      print('Exception details:\n $e');
      print('Stack trace:\n $s');
      message = 'Error calling hello';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted)
      return;

    setState(() {
      _messages = message;
    });
  }

  // Authentication test
  auth(String authPolicy, String username, String password) async {
    dynamic data;
    String message;

    try {
      data = await FhSdk.auth(authPolicy, username, password);
      message = data['message'];
      print('auth data' + data['message']);
    } on PlatformException catch (e, s) {
      print('Exception details:\n $e');
      print('Stack trace:\n $s');
      message = 'Error calling hello';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted)
      return;

    setState(() {
      _messages = message;
    });
  }

  @override
  Widget build(BuildContext context) {
    final TextEditingController _controller = new TextEditingController();
    TitleSection titleSection = new TitleSection();
    Container formSection = new Container(
      padding: const EdgeInsets.all(28.0),
      child: new Row(
        children: [
          new Expanded(
            child: new Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                //new TitleSection(),
                new ListTile(
                  leading: const Icon(Icons.person),
                  title: new TextField(
                    controller: _controller,
                    decoration: new InputDecoration(
                      hintText: "Name",
                    ),
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );

    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Red Hat MAP - Hello Test'),
        ),
        body: new ListView(
          children: [ 
            titleSection,
            formSection,
            const Divider(
              height: 1.0,
            ),
            new Container(
              padding: const EdgeInsets.all(32.0),
              child: new RaisedButton(
                child: new Text(_fhInit ? 'Say Hello' : 'Init in progress...'),
                color: Theme.of(context).primaryColor,
                textColor: Colors.white,
                onPressed: !_fhInit ? null : () {
                  // Perform some action
                  sayHello(_controller.text);
                }
              )
            ),
             new Container(
              padding: const EdgeInsets.all(32.0),
              child: new RaisedButton(
                child: new Text(_fhInit ? 'Test auth' : 'Init in progress...'),
                color: Theme.of(context).primaryColor,
                textColor: Colors.white,
                onPressed: !_fhInit ? null : () {
                  // Perform some action
                  auth('popagame', 'trever', '123');
                  getCloudUrl();
                }
              )
            ),
            new Container(
              padding: const EdgeInsets.all(32.0),
              child: new Card(
                child: new Column(
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    new ListTile(
                      //leading: const Icon(Icons.album),
                      title: const Text('Messages'),
                      subtitle: new Text('$_messages'),
                    )                    
                  ],
                ),
              )
            )
          ]
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  fh_sdk: ^0.6.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:fh_sdk/fh_sdk.dart';
  
Version Uploaded Documentation Archive
0.6.6 May 5, 2018 Go to the documentation of fh_sdk 0.6.6 Download fh_sdk 0.6.6 archive
0.6.5 Apr 26, 2018 Go to the documentation of fh_sdk 0.6.5 Download fh_sdk 0.6.5 archive
0.6.4 Apr 22, 2018 Go to the documentation of fh_sdk 0.6.4 Download fh_sdk 0.6.4 archive
0.6.3 Apr 22, 2018 Go to the documentation of fh_sdk 0.6.3 Download fh_sdk 0.6.3 archive
0.6.2 Apr 18, 2018 Go to the documentation of fh_sdk 0.6.2 Download fh_sdk 0.6.2 archive
0.6.1 Apr 16, 2018 Go to the documentation of fh_sdk 0.6.1 Download fh_sdk 0.6.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
26
Health:
Code health derived from static analysis. [more]
55
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
77
Overall:
Weighted score of the above. [more]
45
Learn more about scoring.

We analyzed this package on May 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.0
  • pana: 0.12.15
  • Flutter: 1.5.8

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Fix lib/fh_sdk.dart. (-44.03 points)

Analysis of lib/fh_sdk.dart failed with 2 errors, 1 hint:

line 23 col 28: Undefined name 'JSON'.

line 38 col 28: Undefined name 'JSON'.

line 2 col 8: Unused import: 'dart:convert'.

Document public APIs. (-1 points)

7 out of 7 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.

Maintenance suggestions

The package description is too short. (-17 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is getting outdated. (-6.03 points)

The package was last published 55 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8