flutter_ibm_watson 0.0.2

Flutter Ibm Watson #

IBM Watson

Installation #

  • Add this to your package's pubspec.yaml file:
dependencies:
  flutter_ibm_watson: ^0.0.1
  • You can install packages from the command line: with Flutter:
$ flutter packages get
  • Import it Now in your Dart code, you can use:
 import 'package:flutter_ibm_watson/flutter_ibm_watson.dart';

Usage #

Language Translator #

    import 'package:flutter_ibm_watson/flutter_ibm_watson.dart';
    // or import
    import 'package:flutter_ibm_watson/language_translator/LanguageTranslator.dart';
    import 'package:flutter_ibm_watson/utils/Language.dart';
    import 'package:flutter_ibm_watson/utils/IamOptions.dart';
  • Code Flutter to translate text
IamOptions options = await IamOptions(iamApiKey: "Your ApiKey", url: "Your Url").build();
LanguageTranslator service = new LanguageTranslator(iamOptions: options);
TranslationResult translationResult = await service.translate("Your Text", Language.ENGLISH, Language.SPANISH);
print(translationResult);
  • Example
void languageTranslator(String text) async {
    IamOptions options = await IamOptions(iamApiKey: "fr8sBBKkjZidQJij6sadfxAwqwqe4S8yY_fdXmSrKZoH_F8LB", url: "https://gateway-syd.watsonplatform.net/language-translator/api").build();
    LanguageTranslator service = new LanguageTranslator(iamOptions: options);
    TranslationResult translationResult = await service.translate(text, Language.ENGLISH, Language.SPANISH);
    print(translationResult);
}

*Code Flutter to identify language

IamOptions options = await IamOptions(iamApiKey: "Your ApiKey", url: "Your Url").build();
LanguageTranslator service = new LanguageTranslator(iamOptions: options);
IdentifyLanguageResult identifyLanguageResult = await service.identifylanguage("You text to identify");
print(identifyLanguageResult);
  • Example
void identifyLanguage(String text) async {
    IamOptions options = await IamOptions(iamApiKey: "fr8sBBKkjZidQJij6sadfxAwqwqe4S8yY_fdXmSrKZoH_F8LB", url: "https://gateway-syd.watsonplatform.net/language-translator/api").build();
    LanguageTranslator service = new LanguageTranslator(iamOptions: this.options);
    IdentifyLanguageResult identifyLanguageResult = await service.identifylanguage(text);
    print(identifyLanguageResult);
}

Visual Recognition #

    import 'package:flutter_ibm_watson/flutter_ibm_watson.dart';
    // or import
    import 'package:flutter_ibm_watson/visual-recognition/VisualRecognition.dart';
    import 'package:flutter_ibm_watson/utils/Language.dart';
    import 'package:flutter_ibm_watson/utils/IamOptions.dart';
  • Code Flutter for Visual Recognition Image Url
IamOptions options = await IamOptions(iamApiKey: "Your ApiKey", url: "Your Url").build();
VisualRecognition visualRecognition = new VisualRecognition(iamOptions: this.options, language: Language.ENGLISH); // Language.ENGLISH is language response 
ClassifiedImages classifiedImages = await visualRecognition.classifyImageUrl("Your Image URLS");
print(classifiedImages.getImages()[0].getClassifiers()[0].getClasses()[0].className);
  • Example
void visualRecognitionUrl(String url) async {
    IamOptions options = await IamOptions(iamApiKey: "PtrAMdthejasdsaqqweXpRSs3gxwQAdsasdRPNzLEnLQ", url: "https://gateway.watsonplatform.net/visual-recognition/api").build();
    VisualRecognition visualRecognition = new VisualRecognition(iamOptions: this.options, language: Language.ENGLISH);
    ClassifiedImages classifiedImages = await visualRecognition.classifyImageUrl(url);
    print(classifiedImages
        .getImages()[0]
        .getClassifiers()[0]
        .getClasses()[0]
        .className);
}
  • Visual Recognition File
IamOptions options = await IamOptions(iamApiKey: "Your ApiKey", url: "Your Url").build();
VisualRecognition visualRecognition = new VisualRecognition(iamOptions: this.options, language: Language.ENGLISH); // Language.ENGLISH is language response 
ClassifiedImages classifiedImages = await visualRecognition.classifyImageFile("Image File Path");
print(classifiedImages.getImages()[0].getClassifiers()[0].getClasses()[0].class_name);
  • Example
void visualRecognitionFile(File image) async {
    IamOptions options = await IamOptions(iamApiKey: "PtrAMdthejasdsaqqweXpRSs3gxwQAdsasdRPNzLEnLQ", url: "https://gateway.watsonplatform.net/visual-recognition/api").build();
    VisualRecognition visualRecognition = new VisualRecognition(
        iamOptions: this.options, language: Language.ENGLISH);
    ClassifiedImages classifiedImages =
        await visualRecognition.classifyImageFile(image.path);

    print(classifiedImages
        .getImages()[0]
        .getClassifiers()[0]
        .getClasses()[0]
        .className);
}

Getting Started #

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

For help on editing package code, view the documentation.

[0.0.2] - TODO: 26-11-2018.

  • TODO: Support dart 2 and added dartdoc

[0.0.1] - TODO: 24-06-2018.

  • TODO: The flutter_ibm_watson makes it easy to integrate IBM Watson

example/README.md

example #

A new Flutter project.

Getting Started #

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

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_ibm_watson: ^0.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:flutter_ibm_watson/flutter_ibm_watson.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
54
Health:
Code health derived from static analysis. [more]
53
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
59
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/utils/Language.dart. (-46.29 points)

Analysis of lib/utils/Language.dart reported 124 hints, including:

line 2 col 3: Prefer using /// for doc comments.

line 3 col 17: Name non-constant identifiers using lowerCamelCase.

line 5 col 3: Prefer using /// for doc comments.

line 6 col 17: Name non-constant identifiers using lowerCamelCase.

line 8 col 3: Prefer using /// for doc comments.

Fix lib/visual-recognition/VisualRecognition.dart. (-0.50 points)

Analysis of lib/visual-recognition/VisualRecognition.dart reported 1 hint:

line 190 col 5: Await only futures.

Format lib/flutter_ibm_watson.dart.

Run flutter format to format lib/flutter_ibm_watson.dart.

Format lib/language_translator/LanguageTranslator.dart.

Run flutter format to format lib/language_translator/LanguageTranslator.dart.

Format lib/utils/IamOptions.dart.

Run flutter format to format lib/utils/IamOptions.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (http).

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 >=1.20.1 <3.0.0
flutter 0.0.0
http ^0.11.3+16 0.11.3+17 0.12.0+2
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.6 1.1.7
path 1.6.2
sky_engine 0.0.99
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test

Admin