bfast 0.0.2-beta

  • Readme
  • Changelog
  • Installing
  • 58

BFast #

BFast client sdk for flutter. Always use latest version to stay up to date. Refer to BFastProject for more documentation and learn more.

Get Started #

Make sure you have your BFast project up and running. Login to your BFast project and create a client apiKey to be used with SDK.

Initiate Sdk #

After install sdk navigate to your main class and add the following code

// some codes and imports

void main(){
    runapp(MyApp());

    BFast().init(serverUrl: '<YOUR_BFAST_SERVER_URL>', apiKey: '<API_KEY>' ); // add this codes
}

// some other codes

NOTE

  • <YOUR_BFAST_SERVER_URL> This is a full hostname with port on which your BFast application is running for example https://demo.bfast:8000. Don't include / at the end f your serverUrl

  • <API_KEY> Api key as you define it to your project

BFast Domain #

This section handle data manipulation of BFast domains

Save data to your domain #

Domain is a schema or model you define to your BFast project, once build and deploy you can save data through various ways as follow

var product = BFast().domain('products');
product
    .set('name', 'XPS 13')
    .set('price', 1000)
    .save()
    .then((value){
        // product added
    }).catch((reason){
        // handle errors
    });

Or you can do this way

var product = BFast().domain('products');
product.set('name', 'XPS 13');
product.set('price', 1000);
product.save().then((value){
    // product added
}).catch((reason){
    // handle errors
});

Or you can do like this

var product = BFast().domain('products');
product.setValues({
    'name': 'XPS 13',
    'price': 1000
}).save().then((value){
    // product added
}).catch((reason){
    // handle errors
});

Response of a save method will be an object like

{message: "<RESPONSE_MESSAGE>"}

Get many domain in pagination #

You can retrive domains from your bfast project as follow.

var product = BFast().domain('products');
product.many().then((value){
    // your logics to handle data
}).catch((reason){
    // handle errors
});

This will return first 20 domain objects from your bfast projects as a default pagination. Or you can pass optinal params as follow

var product = BFast().domain('products');
product.many({
    "size": 100, // data returned size [option]
    "page": 0, // starting page [option]
    "order": "name" // order results by name [option]
}).then((value){
    // your logics to handle data
}).catch((reason){
    // handle errors
});

When request is succesfull, response will be of the following format. Note DOMAIN_NAME mean the name of the domain you request data in this example products

{
    [DOMAIN_NAME]: Array,
    page: Object,
    links: Object
}

page property contain information abount pagination of data, links contain information on how to navigate between data and propert [DOMAIN_NAME] contain array of request data

Get a single object of a domain #

To get a single object of a domain we can either use link of that object or its objectId.

  • By using link
var product = BFast().domain('products');
product.one(link: '<OBJECT_LINK>').then((value){
    // your logics to handle object data  
}).catch((reason){
    //  handle errors
});
  • By using objectId/id
var product = BFast().domain('products');
product.one(id: '<OBJECT_ID>').then((value){
    // your logics to handle object data  
}).catch((reason){
    //  handle errors
});
  • When pass both link and id. link will be used instead of id
var product = BFast().domain('products');
product.one(link: '<OBJECT_LINK>', id: '<OBJECT_ID>').then((value){
    // your logics to handle object data  
}).catch((reason){
    //  handle errors
});

Response will be of the following format

{
    [DOMAIN_NAME]: Object
}

Update Domain #

To update a single object of a domain we can either use link of that object or its objectId.

  • By using link
var product = BFast().domain('products');
product.set('name', 'XPS 15');
product.set('price', 3000);
product.update(link: '<OBJECT_LINK>').then((value){
    // object updated
}).catch((reason){
    //  handle errors
});
  • By using objectId/id
var product = BFast().domain('products');
product.set('name', 'XPS 15');
product.set('price', 3000);
product.update(id: '<OBJECT_ID>').then((value){
    // object updated
}).catch((reason){
    //  handle errors
});
  • When pass both link and id. link will be used instead of id
var product = BFast().domain('products');
product.set('name', 'XPS 15');
product.set('price', 3000);
product.update(link: '<OBJECT_LINK>', id: '<OBJECT_ID>').then((value){
    // object updated  
}).catch((reason){
    //  handle errors
});

Response will be of the following format

{
    message: <MESSAGE_FROM_SERVER>
}

Delete Domain #

To delete a domain we can either use link of that object or its objectId.

  • By using link
var product = BFast().domain('products');
product.delete(link: '<OBJECT_LINK>').then((value){
    // object deleted
}).catch((reason){
    //  handle errors
});
  • By using objectId/id
var product = BFast().domain('products');
product.delete(id: '<OBJECT_ID>').then((value){
    // object deleted  
}).catch((reason){
    //  handle errors
});
  • When pass both link and id. link will be used instead of id
var product = BFast().domain('products');
product.delete(link: '<OBJECT_LINK>', id: '<OBJECT_ID>').then((value){
    // object deleted
}).catch((reason){
    //  handle errors
});

Response will be of the following format

{
    message: <MESSAGE_FROM_SERVER>
}

Call a query from BFast project #

You can call a query defined to your domain from BFast console/project as follow. Let say we define a query in our domain called findAllByName

var product = BFast().domain('products');
product.search('findAllByName',{
    "name": "XPS 13"
}).then((value){
    // your logic to handle results
}).catch((reason){
    // handle error
})

When request is succesfull, response will be of the following format. Note DOMAIN_NAME mean the name of the domain you request data in this example products

{
    [DOMAIN_NAME]: dynamic, // depend on return of query
    page: Object, // option, can be null
    links: Object // option, can be null
}

page property contain information abount pagination of data, links contain information on how to navigate between data and propert [DOMAIN_NAME] contain array of request data

Pagination support #

You can navigate forward and backward through your data pr jump to a specific page by as follow

var product = BFast().domain('products');
product.navigate('<LINK_OF_NEXT_DATA>').then((value){
    // handle next data
}).catch((reason){
    // handle errors
});

When request is succesfull, response will be of the following format. Note DOMAIN_NAME mean the name of the domain you request data in this example products

{
    [DOMAIN_NAME]: Array,
    page: Object,
    links: Object
}

page property contain information abount pagination of data, links contain information on how to navigate between data and propert [DOMAIN_NAME] contain array of request data

BFast Function #

BFast project support function as a service or cloud function which you can call it as follow

BFast().fun('hello').run().then((value){
    // handle your function results
}).catch((reason){
    // handle erros
})

You can pass body to your function to as follow

BFast().fun('hello').run({
    "name": "Joshua"
}).tne((value){
    // handle your function results
}).catch((reason){
    // handle errors
});

Response will be as you return from your function

BFast Client Sdk #

Refer to BFastProject for better documentations. Always use latest version

[0.0.2-beta] - 31/08/2019

Add documentation and minor patch to reduce library size

[0.0.1-beta] - 31/08/2019

Initial release

Use this package as a library

1. Depend on it

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


dependencies:
  bfast: ^0.0.2-beta

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:bfast/bfast.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
43
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
35
Overall:
Weighted score of the above. [more]
58
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

50 out of 50 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/configuration.dart.

Run flutter format to format lib/configuration.dart.

Format lib/controller/domain.dart.

Run flutter format to format lib/controller/domain.dart.

Format lib/controller/function.dart.

Run flutter format to format lib/controller/function.dart.

Format lib/core/domain.dart.

Run flutter format to format lib/core/domain.dart.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field http://bfast.fahamutech.com/docs was unreachable.

The package description is too short. (-20 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.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and bfast.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

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.

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
http ^0.12.0+2 0.12.0+2
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
http_parser 3.1.3
meta 1.1.7
path 1.6.4
pedantic 1.8.0+1
sky_engine 0.0.99
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
mockito ^4.1.0